Performance optimizations for id and | rules

This commit is contained in:
Bruce Hill 2021-01-18 12:39:44 -08:00
parent 218ea864e1
commit 71471476be
3 changed files with 12 additions and 8 deletions

View File

@ -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,_

View File

@ -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,!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,_,~

View File

@ -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)