code / bp

Lines4.3K C3.3K Markdown541 YAML273 make110 Shell77 Lua54
(22 lines)
1 # Syntax definition for some Javascript-specific patterns
2 #
3 # NOTE: this is *NOT* intended to be a complete definition of the language's
4 # syntax! Providing a full language grammar is overkill, because the intended
5 # use case is finding/replacing string patterns. This task does not require a
6 # full parse tree, and having one makes the task considerably more complicated.
7 # See the accompanying README.md for more info.
9 comment: "//" .. $ / "/*" ..%\n "*/"
10 string: `" ..%string-escape `" / `' ..%string-escape `' / `/ ..%string-escape `/
11 keyword: ("abstract" / "arguments" / "await" / "boolean" / "break" / "byte" / "case" /
12 "catch" / "char" / "class" / "const" / "continue" / "debugger" / "default" /
13 "delete" / "do" / "double" / "else" / "enum" / "eval" / "export" / "extends" /
14 "false" / "final" / "finally" / "float" / "for" / "function" / "goto" / "if" /
15 "implements" / "import" / "in" / "instanceof" / "int" / "interface" / "let" /
16 "long" / "native" / "new" / "null" / "package" / "private" / "protected" /
17 "public" / "return" / "short" / "static" / "super" / "switch" / "synchronized" /
18 "this" / "throw" / "throws" / "transient" / "true" / "try" / "typeof" / "var" /
19 "void" / "volatile" / "while" / "with" / "yield")
20 function-def: |"function"| __ [id__] parens / (id / parens) __ "=>"
21 function: function-def __ braces
22 import: |"import"| ..%braces (`; / $)