Last active
December 18, 2015 12:49
-
-
Save samuraisam/5785740 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
grammar NewStrLiteralTest { | |
token TOP { <string> } | |
proto token string { * } | |
token string:sym<single-quoted> { \' ~ \' ( <-[\\\x00\n']>+ | <str_escape> )* } | |
token string:sym<double-quoted> { \" ~ \" ( <-[\\\x00\n"]>+ | <str_escape> )* } | |
token str_escape { | |
[ <hex-escape> | <oct-escape> | <char-escape> ] | |
} | |
token hex-escape { '\\' <[xX]> <.xdigit> ** 1..2 } | |
token oct-escape { '\\' <[0..7]> ** 1..3 } | |
token char-escape { '\\' <[abfnrtv\\?'"]> } | |
} | |
say NewStrLiteralTest.parse('"hello \nworl\x00d"'); | |
say NewStrLiteralTest.parse('\'hello w"h\nirld\''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment