Created
October 17, 2018 10:47
-
-
Save scientific-coder/cbe199b4b994952b60d18263aa37e704 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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