Skip to content

Instantly share code, notes, and snippets.

@hdemon
Created February 5, 2015 03:15
Show Gist options
  • Save hdemon/e3088d63c9c194e197fd to your computer and use it in GitHub Desktop.
Save hdemon/e3088d63c9c194e197fd to your computer and use it in GitHub Desktop.
/*
* Classic example grammar, which recognizes simple arithmetic expressions like
* "2*(3+4)". The parser generated from this grammar then computes their value.
*/
start
= right:digits " plus " left:digits {
return right + left;
}
digits
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment