Skip to content

Instantly share code, notes, and snippets.

@scientific-coder
Created October 17, 2018 10:47
Show Gist options
  • Save scientific-coder/cbe199b4b994952b60d18263aa37e704 to your computer and use it in GitHub Desktop.
Save scientific-coder/cbe199b4b994952b60d18263aa37e704 to your computer and use it in GitHub Desktop.
(def addmult-parser
(instaparse.core/parser
"prog= spaces? add-sub spaces?
<add-sub> = mult-div | add | sub
add= add-sub spaces? <'+'> spaces? mult-div
sub= add-sub spaces? <'-'> spaces? mult-div
<mult-div> = number | mult | div
mult= mult-div spaces? <'*'> spaces? number
div= mult-div spaces? <'/'> spaces? number
number= #'-?[0-9]+'
<spaces> = <#'\\s+'>"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment