diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-12 18:28:19 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-12 18:28:19 -0400 |
commit | 8733d14e6e719f1f3b0d677b1938d846baf13fd0 (patch) | |
tree | 3572d46734efb761c1f3264618bcda6380ed59f5 /minic | |
parent | 095ebf62f10ca073b29fe1434ea3cf59dab44bbb (diff) | |
download | roux-8733d14e6e719f1f3b0d677b1938d846baf13fd0.tar.gz |
add & binop to minic
Diffstat (limited to 'minic')
-rw-r--r-- | minic/minic.y | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/minic/minic.y b/minic/minic.y index c66ac65..3843b54 100644 --- a/minic/minic.y +++ b/minic/minic.y @@ -312,6 +312,7 @@ expr(Node *n) ['*'] = "mul", ['/'] = "div", ['%'] = "rem", + ['&'] = "and", ['<'] = "cslt", /* meeeeh, careful with pointers/long */ ['l'] = "csle", ['e'] = "ceq", @@ -571,12 +572,11 @@ mkstmt(int t, void *p1, void *p2, void *p3) %token IF ELSE WHILE BREAK RETURN %right '=' +%left '&' %left EQ NE %left '<' '>' LE GE %left '+' '-' %left '*' '/' '%' -%nonassoc '&' -%nonassoc '[' %type <u> type %type <s> stmt stmts @@ -584,7 +584,7 @@ mkstmt(int t, void *p1, void *p2, void *p3) %% -prog: func prog | fdcl prog | ; +prog: func prog | fdcl prog | idcl prog | ; fdcl: type IDENT '(' ')' ';' { @@ -660,6 +660,7 @@ expr: pref | expr GE expr { $$ = mknode('l', $3, $1); } | expr EQ expr { $$ = mknode('e', $1, $3); } | expr NE expr { $$ = mknode('n', $1, $3); } + | expr '&' expr { $$ = mknode('&', $1, $3); } ; pref: post |