Created
October 17, 2018 10:57
-
-
Save scientific-coder/efad2293535b715e3fba175f27df3ed6 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 arith-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> = term | mult | div | |
mult = mult-div spaces? <'*'> spaces? term | |
div = mult-div spaces? <'/'> spaces? term | |
<term> = number | <'('> add-sub <')'> | |
<spaces> = <#'\\s'+> | |
number = #'-?[0-9]+'")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment