diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-18 12:39:44 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-18 12:39:44 -0800 |
| commit | 71471476be004f65abb75cd3817046dcf433d203 (patch) | |
| tree | 9f827325be715b92a4bd3f493653f4f29efade67 /grammars | |
| parent | 218ea864e133f8dd10b3c189eb07a5c56286e792 (diff) | |
Performance optimizations for `id` and `|` rules
Diffstat (limited to 'grammars')
| -rw-r--r-- | grammars/builtins.bp | 8 | ||||
| -rw-r--r-- | grammars/lisp.bp | 4 | ||||
| -rw-r--r-- | grammars/utf8-id.bp | 8 |
3 files changed, 12 insertions, 8 deletions
diff --git a/grammars/builtins.bp b/grammars/builtins.bp index e5106c0..937db3c 100644 --- a/grammars/builtins.bp +++ b/grammars/builtins.bp @@ -16,13 +16,9 @@ brackets: `[..`] % (\n/brackets/string) braces: `{..`} % (\n/braces/string) parens: `(..`) % (\n/parens/string) string: `"..`" % (`\.) / `'..`' % (`\.) -id: | (!`0-9 id-char *id-char)!=keyword | +id: !<`a-z,A-Z,_,0-9 (`a-z,A-Z,_ *`a-z,A-Z,_,0-9)!=keyword | id-char: `a-z,A-Z,_,0-9 -|: !id-char / ( - !<(\x00-x7f==id-char) - !<((\xc0-xdf \x80-xbf)==id-char) - !<((\xe0-xef 2\x80-xbf)==id-char) - !<((\xf0-xf7 3\x80-xbf)==id-char)) +|: !<`a-z,A-Z,_,0-9 / !`a-z,A-Z,_,0-9 var: id keyword: !"" # No keywords defined by default word: |+`a-z,A-Z !`0-9,_ diff --git a/grammars/lisp.bp b/grammars/lisp.bp index 5dd2965..a3e525c 100644 --- a/grammars/lisp.bp +++ b/grammars/lisp.bp @@ -11,4 +11,6 @@ string: `" .. `" % (`\.) list: parens function-def: `(__"defun"|__id function: function-def .. `) % parens -id-char: `A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ +id-char: `A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ +id: !<`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ +`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ +|: !<`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ / !`A-Z,a-z,0-9,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~ diff --git a/grammars/utf8-id.bp b/grammars/utf8-id.bp index f137104..9d5381d 100644 --- a/grammars/utf8-id.bp +++ b/grammars/utf8-id.bp @@ -1,5 +1,11 @@ # Definitions of UTF8-compliant identifiers -utf8-id: utf8-id-start *utf8-id-cont +id: | utf8-id-start *utf8-id-cont +id-char: utf8-id-cont / utf8-id-start +|: !id-char / ( + !<(\x00-x7f==id-char) + !<((\xc0-xdf \x80-xbf)==id-char) + !<((\xe0-xef 2\x80-xbf)==id-char) + !<((\xf0-xf7 3\x80-xbf)==id-char)) utf8-id-start: `A-Z / `a-z / !\x00-x7F ( \xc2 (\xaa / \xb5 / \xba) |
