Skip to content

Instantly share code, notes, and snippets.

@mroeder
Forked from rtoal/Arithmetic.json
Last active December 9, 2016 21:18
Show Gist options
  • Save mroeder/b18f82d8566ebd536893d507fa6e843c to your computer and use it in GitHub Desktop.
Save mroeder/b18f82d8566ebd536893d507fa6e843c to your computer and use it in GitHub Desktop.
Ray's Awesome Arithmetic
Arithmetic {
Exp
= AddExp
AddExp
= AddExp "+" MulExp -- plus
| AddExp "-" MulExp -- minus
| MulExp
MulExp
= MulExp "*" ExpExp -- times
| MulExp "/" ExpExp -- divide
| ExpExp
ExpExp
= PriExp "^" ExpExp -- power
| PriExp
PriExp
= "(" Exp ")" -- paren
| "+" PriExp -- pos
| "-" PriExp -- neg
| ident
| number
ident (an identifier)
= letter alnum*
number (a number)
= digit* "." digit+ -- fract
| digit+ -- whole
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment