Created
January 15, 2014 07:36
-
-
Save joeriks/8432276 to your computer and use it in GitHub Desktop.
peg grammar for simple syntax name:type
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
| start | |
| = (member:MEMBER "\n"+ {return member})* | |
| MEMBER = c:[a-z]+ " "* t:(":" t:MEMBERTYPE{return t})? {return {name:c.join(""),type:t}} | |
| MEMBERTYPE = type:('key'/'number'/'string') {return type;} | |
| /* | |
| foo:string | |
| bar:key | |
| */ | |
| [ | |
| { | |
| "name": "foo", | |
| "type": "string" | |
| }, | |
| { | |
| "name": "bar", | |
| "type": "key" | |
| } | |
| ] | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment