(22 lines)
1 # Syntax definition for some Javascript-specific patterns2 #3 # NOTE: this is *NOT* intended to be a complete definition of the language's4 # syntax! Providing a full language grammar is overkill, because the intended5 # use case is finding/replacing string patterns. This task does not require a6 # 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 __ braces22 import: |"import"| ..%braces (`; / $)