diff options
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/javascript.bp | 24 | ||||
| l--------- | grammars/js.bp | 1 | ||||
| -rw-r--r-- | grammars/python.bp | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/grammars/javascript.bp b/grammars/javascript.bp new file mode 100644 index 0000000..49322c2 --- /dev/null +++ b/grammars/javascript.bp @@ -0,0 +1,24 @@ +# Syntax definition for some Javascript-specific patterns +# +# NOTE: this is *NOT* intended to be a complete definition of the language's +# syntax! Providing a full language grammar is overkill, because the intended +# use case is finding/replacing string patterns. This task does not require a +# full parse tree, and having one makes the task considerably more complicated. +# See the accompanying README.md for more info. + +comment: "//" .. $ / "/*" .. "*/" % \n +string: `"..`" % (`\.) / `'..`' % (`\.) / `/ .. `/ % (`\.) +keyword: |( + "abstract" / "arguments" / "await" / "boolean" / "break" / "byte" / "case" / + "catch" / "char" / "class" / "const" / "continue" / "debugger" / "default" / + "delete" / "do" / "double" / "else" / "enum" / "eval" / "export" / "extends" / + "false" / "final" / "finally" / "float" / "for" / "function" / "goto" / "if" / + "implements" / "import" / "in" / "instanceof" / "int" / "interface" / "let" / + "long" / "native" / "new" / "null" / "package" / "private" / "protected" / + "public" / "return" / "short" / "static" / "super" / "switch" / "synchronized" / + "this" / "throw" / "throws" / "transient" / "true" / "try" / "typeof" / "var" / + "void" / "volatile" / "while" / "with" / "yield" +)| +function-def: |"function"| __ [id__] parens / (id / parens) __ "=>" +function: function-def __ braces +import: |"import"| ..(`; / $) % braces diff --git a/grammars/js.bp b/grammars/js.bp new file mode 120000 index 0000000..678a965 --- /dev/null +++ b/grammars/js.bp @@ -0,0 +1 @@ +javascript.bp
\ No newline at end of file diff --git a/grammars/python.bp b/grammars/python.bp index 6928580..938b53e 100644 --- a/grammars/python.bp +++ b/grammars/python.bp @@ -17,4 +17,4 @@ class: class-def +(\N ..$) class-def: ^_|"class"|_id[_parens]_`: function: function-def +(\N ..$) function-def: ^_|"def"|_id parens `: -import: |"import"| _ (parens / *id%(_`,__)) [_ |"as"| (parens / *id%(_`,__))] +import: ^_["from"| ..>(|"import"|)] (|"import"|)%parens ..$%parens |
