Created
October 17, 2018 11:05
-
-
Save scientific-coder/96f96d720d42c5e2c9b9a42773b07ae9 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 lang0-parser | |
(instaparse.core/parser | |
"prog = (spaces? expr spaces? <';'> spaces?)* | |
<expr> = assig | add-sub | |
assig = varname spaces? <'='> spaces? expr | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = factor | mult |div | |
mult = mult-div spaces? <'*'> spaces? factor | |
div = mult-div spaces? <'/'> spaces? factor | |
<factor> = number | <'('> spaces? expr spaces? <')'> | varget |assig | |
<spaces> = <#'\\s+'> | |
number = #'-?[0-9]+' | |
varget = varname | |
varname = #'[a-zA-Z]\\w*'")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment