Created
February 28, 2014 03:32
-
-
Save barik/9264676 to your computer and use it in GitHub Desktop.
Grammar
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 p_exp_int(p): | |
'exp : INT' | |
p[0] = ast.Num(p[1], p.lineno(1)) | |
def p_exp_bool_true(p): | |
'exp : TRUE' | |
p[0] = ast.Bool(True, p.lineno(1)) | |
def p_exp_bool_false(p): | |
'exp : FALSE' | |
p[0] = ast.Bool(False, p.lineno(1)) | |
... | |
def p_exp_binary(p): | |
''' | |
exp : exp PLUS exp | |
| exp MINUS exp | |
| exp STAR exp | |
| exp SLASH exp | |
| exp MOD exp | |
| exp EQ exp | |
| exp NEQ exp | |
| exp GT exp | |
| exp LT exp | |
| exp GE exp | |
| exp LE exp | |
''' | |
p[0] = ast.BinOp(p[1], p[2], p[3], p.lineno(3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment