Skip to content

Instantly share code, notes, and snippets.

@samuraisam
Last active December 18, 2015 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuraisam/5790917 to your computer and use it in GitHub Desktop.
Save samuraisam/5790917 to your computer and use it in GitHub Desktop.
proto token constant { * }
# int
token constant:sym<int> { <int-lit> }
proto token int-lit { * }
token int-lit:sym<dec> { '-'? <[1..9]>\d* }
token int-lit:sym<hex> { '-'? '0' <[xX]> <.xdigit>+ }
token int-lit:sym<oct> { '-'? '0' <[0..7]>* }
# other numbers
token constant:sym<float> { '-'? \d+ '.'? [\d+]? [<[eE]> ['+'|'-']? \d+]? }
token constant:sym<bool> { 'true' | 'false' }
# string
token constant:sym<str> { <str-lit> }
proto token str-lit { * }
token str-lit:sym<single-quoted> { \' ~ \' ( <-[\\\x00\n']>+ | <str-escape> )* }
token str-lit:sym<double-quoted> { \" ~ \" ( <-[\\\x00\n"]>+ | <str-escape> )* }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment