Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Created April 23, 2012 00:50
Show Gist options
  • Save wyattdanger/2467862 to your computer and use it in GitHub Desktop.
Save wyattdanger/2467862 to your computer and use it in GitHub Desktop.
simple parser in peg.js
start =
expression
expression =
_ a:atom
{ return a }
/ _ "(" a:expression b:expression* ")"
{ return [a].concat(b) }
validchar =
[0-9a-zA-Z_?!+\-=@#$%^&*/.]
atom =
chars:validchar+
{ return chars.join(""); }
_ =
whitespace*
whitespace =
[" "]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment