-
-
Save samuraisam/5790917 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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