Created
August 9, 2010 11:07
-
-
Save sinkovsky/515287 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use v6; | |
| grammar JSON::Tiny::Grammar; | |
| rule TOP { ^[ <object> | <array> ]$ } | |
| rule object { '{' ~ '}' <pairlist> } | |
| rule pairlist { [ <pair> ** [ \, ] ]? } | |
| rule pair { <string> ':' <value> } | |
| rule array { '[' ~ ']' [ <value> ** [ \, ] ]? } | |
| proto token value { <...> }; | |
| token value:sym<number> { | |
| '-'? | |
| [ 0 | <[1..9]> <[0..9]>* ] | |
| [ \. <[0..9]>+ ]? | |
| [ <[eE]> [\+|\-]? <[0..9]>+ ]? | |
| } | |
| token value:sym<true> { <sym> }; | |
| token value:sym<false> { <sym> }; | |
| token value:sym<null> { <sym> }; | |
| token value:sym<object> { <object> }; | |
| token value:sym<array> { <array> }; | |
| token value:sym<string> { <string> } | |
| token string { | |
| \" ~ \" [ <str> | \\ <str_escape> ]* | |
| } | |
| token str { | |
| [ | |
| <!before \t> | |
| <!before \n> | |
| <!before \\> | |
| <!before \"> | |
| . | |
| ]+ | |
| # <-["\\\t\n]>+ | |
| } | |
| token str_escape { | |
| <["\\/bfnrt]> | u <xdigit>**4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment