Skip to content

Instantly share code, notes, and snippets.

@joeriks
Created January 15, 2014 07:36
Show Gist options
  • Select an option

  • Save joeriks/8432276 to your computer and use it in GitHub Desktop.

Select an option

Save joeriks/8432276 to your computer and use it in GitHub Desktop.
peg grammar for simple syntax name:type
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