diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-08-01 12:40:27 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-08-01 12:40:27 -0700 |
| commit | 994c9c973e0fd771699c3a5c76bee11f9b744c84 (patch) | |
| tree | 8257c1abe2d18a50a46a1d712eadbd25fd7e4f8b /grammars | |
| parent | cb9b4c40d87480bc794b90c2a36ed0f4c3240d8a (diff) | |
Changed how definitions work
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/bp.bp | 8 | ||||
| -rw-r--r-- | grammars/c++.bp | 5 | ||||
| -rw-r--r-- | grammars/c.bp | 5 | ||||
| -rw-r--r-- | grammars/go.bp | 5 | ||||
| -rw-r--r-- | grammars/javascript.bp | 5 | ||||
| -rw-r--r-- | grammars/lua.bp | 7 | ||||
| -rw-r--r-- | grammars/python.bp | 4 | ||||
| -rw-r--r-- | grammars/rust.bp | 5 | ||||
| -rw-r--r-- | grammars/shell.bp | 5 |
9 files changed, 21 insertions, 28 deletions
diff --git a/grammars/bp.bp b/grammars/bp.bp index 3374f0c..2b0f4f9 100644 --- a/grammars/bp.bp +++ b/grammars/bp.bp @@ -12,13 +12,13 @@ Def: @name=id __ `: __ ( / (!)(..%\n>(`;/id_`:/$) => "Invalid definition: @0")) # This is used for command line arguments: - String-pattern: ..%(\n / Nodent / Identifier-char / Identifier-start / Escape / `\ pat [`;])$$ +String-pattern: ..%(\n / Nodent / Identifier-char / Identifier-start / Escape / `\ pat [`;])$$ pat: simple-pat !(__("!~"/"~")) / suffixed-pat -simple-pat: Upto-and / Dot / Word-boundary/ String / Chars / Nodent +simple-pat: (Upto-and / Dot / Word-boundary/ String / Chars / Nodent / Identifier-char / Identifier-start / Escape-range / Escape / Repeat / Optional / No / After / Before / Capture / Error / Empty-replacement - / Start-of-File / Start-of-Line / End-of-File / End-of-Line / Ref / parens + / Start-of-File / Start-of-Line / End-of-File / End-of-Line / Ref / parens) suffixed-pat: ( Match-pat @@ -51,7 +51,7 @@ Nodent: "\N" Word-boundary: `| / "\b" Identifier-char: "\i" Identifier-start: "\I" -Upto-and: ".." [__(`%/`=)__@second=simple-pat] [__@first=simple-pat] +Upto-and: ".." [__(`%/`=)__@second=simple-pat] [__@first=simple-pat] Repeat: ( @min=(=>'0') (`*=>"-") @max=(=>'∞') / @min=int __ `- __ @max=int diff --git a/grammars/c++.bp b/grammars/c++.bp index 1814320..d6135b2 100644 --- a/grammars/c++.bp +++ b/grammars/c++.bp @@ -8,8 +8,7 @@ comment: "//" .. $ / "/*" ..%\n "*/" string: `" ..%string-escape `" -keyword: - "alignas" / "alignof" / "and" / "and_eq" / "asm" / "atomic_cancel" / "atomic_commit" / +keyword: ("alignas" / "alignof" / "and" / "and_eq" / "asm" / "atomic_cancel" / "atomic_commit" / "atomic_noexcept" / "auto" / "bitand" / "bitor" / "bool" / "break" / "case" / "catch" / "char" / "char8_t" / "char16_t" / "char32_t" / "class" / "compl" / "concept" / "const" / "consteval" / "constexpr" / "constinit" / "const_cast" / "continue" / "co_await" / @@ -21,7 +20,7 @@ keyword: "requires" / "return" / "short" / "signed" / "sizeof" / "static" / "static_assert" / "static_cast" / "struct" / "switch" / "synchronized" / "template" / "this" / "thread_local" / "throw" / "true" / "try" / "typedef" / "typeid" / "typename" / "union" / - "unsigned" / "using" / "virtual" / "void" / "volatile" / "wchar_t" / "while" / "xor" / "xor_eq" + "unsigned" / "using" / "virtual" / "void" / "volatile" / "wchar_t" / "while" / "xor" / "xor_eq") function-def: ^_ 2+(id / keyword / anglebraces / `*) % __ parens (__`; / >(__`{)) function: function-def __ braces macro: ^"#define"| ..$ *(<`\ \n..$) diff --git a/grammars/c.bp b/grammars/c.bp index 03403eb..31e123a 100644 --- a/grammars/c.bp +++ b/grammars/c.bp @@ -9,12 +9,11 @@ comment: "//" .. $ / "/*" ..%\n "*/" string: `" ..%string-escape `" string-escape: `\ (`x 2 Hex / 1-3 `0-7 / .) -keyword: - "auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" / +keyword: ("auto" / "break" / "case" / "char" / "const" / "continue" / "default" / "do" / "double" / "else" / "enum" / "extern" / "float" / "for" / "goto" / "if" / "int" / "long" / "register" / "return" / "short" / "signed" / "sizeof" / "static" / "struct" / "switch" / "typedef" / "union" / "unsigned" / "void" / - "volatile" / "while" + "volatile" / "while") function-def: ^_ 2+(id / keyword / `*) % __ parens (__`; / >(__`{)) function: function-def __ braces macro: ^"#define"| ..$ *(<`\ \n..$) diff --git a/grammars/go.bp b/grammars/go.bp index f31e21c..c6f41c1 100644 --- a/grammars/go.bp +++ b/grammars/go.bp @@ -8,10 +8,9 @@ comment: "//" .. $ / "/*" ..%\n "*/" string: `" ..%string-escape `" -keyword: - "break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" / +keyword: ("break" / "default" / "func" / "interface" / "select" / "case" / "defer" / "go" / "map" / "struct" / "chan" / "else" / "goto" / "package" / "switch" / "const" / - "fallthrough" / "if" / "range" / "type" / "continue" / "for" / "import" / "return" / "var" + "fallthrough" / "if" / "range" / "type" / "continue" / "for" / "import" / "return" / "var") function-def: |"func"| __ id __ parens __ [id / parens] >(__`{) function: function-def __ braces import: |"import"| __ (parens / string) diff --git a/grammars/javascript.bp b/grammars/javascript.bp index 438ddab..2691c62 100644 --- a/grammars/javascript.bp +++ b/grammars/javascript.bp @@ -8,8 +8,7 @@ comment: "//" .. $ / "/*" ..%\n "*/" string: `" ..%string-escape `" / `' ..%string-escape `' / `/ ..%string-escape `/ -keyword: - "abstract" / "arguments" / "await" / "boolean" / "break" / "byte" / "case" / +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" / @@ -17,7 +16,7 @@ keyword: "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" + "void" / "volatile" / "while" / "with" / "yield") function-def: |"function"| __ [id__] parens / (id / parens) __ "=>" function: function-def __ braces import: |"import"| ..%braces (`; / $) diff --git a/grammars/lua.bp b/grammars/lua.bp index 6005514..3d3b862 100644 --- a/grammars/lua.bp +++ b/grammars/lua.bp @@ -9,10 +9,9 @@ comment: "--" (`[ @eqs=*`= `[ ..%\n (`]eqs`]) / ..$) string: `"..%string-escape `" / `' ..%string-escape `' / `[ @eqs=*`= `[ ..%\n (`]eqs`]) table: `{ ..%(table/string/comment/\n) `} -keyword: - "and" / "break" / "do" / "else" / "elseif" / "end" / "false" / "for" / - "function" / "goto" / "if" / "in" / "local" / "nil" / "not" / "or" / - "repeat" / "return" / "then" / "true" / "until" / "while" +keyword: ("and" / "break" / "do" / "else" / "elseif" / "end" / "false" / "for" / + "function" / "goto" / "if" / "in" / "local" / "nil" / "not" / "or" / + "repeat" / "return" / "then" / "true" / "until" / "while") function-def: |"function"|[_id (*(`.id)[`:id])]_ parens block: function / if-block / while-block / for-block / repeat-block / do-block repeat-block: |"repeat"| ..%(comment/string/\n) (|"until"|) diff --git a/grammars/python.bp b/grammars/python.bp index 51c3c44..ee749d0 100644 --- a/grammars/python.bp +++ b/grammars/python.bp @@ -8,11 +8,11 @@ comment: `# ..$ string: "'''" ..%\n "'''" / '"""' ..%\n '"""' / `" ..%string-escape `" / `' ..%string-escape `' -keyword: "and" / "as" / "assert" / "break" / "class" / "continue" / "def" / +keyword: ("and" / "as" / "assert" / "break" / "class" / "continue" / "def" / "del" / "elif" / "else" / "except" / "finally" / "for" / "from" / "global" / "if" / "import" / "in" / "is" / "lambda" / "None" / "nonlocal" / "not" / "or" / "pass" / "raise" / "return" / "try" / "while" / - "with" / "yield" + "with" / "yield") class: class-def +(\N ..$) class-def: ^_"class"|_id[_parens]_`: function: function-def +(\N ..$) diff --git a/grammars/rust.bp b/grammars/rust.bp index 4df6b53..9ac459b 100644 --- a/grammars/rust.bp +++ b/grammars/rust.bp @@ -8,11 +8,10 @@ comment: "//" .. $ / "/*" ..%(comment / \n) "*/" string: `" ..%string-escape `" -keyword: - "as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" / +keyword: ("as" / "break" / "const" / "continue" / "crate" / "else" / "enum" / "extern" / "false" / "fn" / "for" / "if" / "impl" / "in" / "let" / "loop" / "match" / "mod" / "move" / "mut" / "pub" / "ref" / "return" / "self" / "Self" / "static" / - "struct" / "super" / "trait" / "true" / "type" / "unsafe" / "use" / "where" / "while" + "struct" / "super" / "trait" / "true" / "type" / "unsafe" / "use" / "where" / "while") function-def: |"fn"| __ id __ parens __ ["->"__(id / parens)] >(__`{) function: function-def __ braces import: |"use"| _ *(id / braces) % "::" _ `; diff --git a/grammars/shell.bp b/grammars/shell.bp index 72b83cc..76cdcfa 100644 --- a/grammars/shell.bp +++ b/grammars/shell.bp @@ -10,10 +10,9 @@ comment: `#..$ string: `" ..%(string-escape / subcommand / \n) `" / `' ..%\n `' / "<<" _ @delim=id _$ ..%\n (^delim$) string-escape: `\ `",` subcommand: `` ..%\n `` / "$" (parens/braces) -keyword: - "echo" / "read" / "set" / "unset" / "readonly" / "shift" / "export" / "if" / "fi" / +keyword: ("echo" / "read" / "set" / "unset" / "readonly" / "shift" / "export" / "if" / "fi" / "else" / "while" / "do" / "done" / "for" / "until" / "case" / "esac" / "break" / - "continue" / "exit" / "return" / "trap" / "wait" / "eval" / "exec" / "ulimit" / "umask" + "continue" / "exit" / "return" / "trap" / "wait" / "eval" / "exec" / "ulimit" / "umask") function-def: ^_ ["function"_] id _ `(_`) >(__`{) function: function-def __ braces var: `$ (id / braces) |
