Fixed precedence on '-'. Passed additional tests. Comments on bad.py. Updated worklog.
This commit is contained in:
@@ -239,6 +239,7 @@ terminal String LBR;
|
||||
terminal String RBR;
|
||||
terminal String ARROW;
|
||||
terminal String IS;
|
||||
terminal String UMINUS;
|
||||
|
||||
|
||||
/* Returned by the lexer for erroneous tokens. Since it does not appear in
|
||||
@@ -282,6 +283,7 @@ precedence left NOT;
|
||||
precedence nonassoc EQUAL, NEQ, LT, GT, LEQ, GEQ, IS;
|
||||
precedence left PLUS, MINUS;
|
||||
precedence left MUL, DIV, MOD;
|
||||
precedence left UMINUS;
|
||||
precedence left DOT, COMMA, LBR, RBR;
|
||||
precedence right IF, ELSE;
|
||||
|
||||
@@ -295,8 +297,11 @@ start with program;
|
||||
|
||||
/* program */
|
||||
program ::= program_head:d opt_stmt_list:s
|
||||
{: RESULT = new Program(d.isEmpty() ? getLeft(s) : getLeft(d),
|
||||
sxright, d, s, errors);
|
||||
{:
|
||||
ComplexSymbolFactory.Location left = d.isEmpty() ? getLeft(s) : getLeft(d);
|
||||
if(left == null)
|
||||
left = new ComplexSymbolFactory.Location(1,1);
|
||||
RESULT = new Program(left, sxright, d, s, errors);
|
||||
:}
|
||||
;
|
||||
|
||||
@@ -400,7 +405,7 @@ else_body ::= ELSE:el COLON block:b {: RES
|
||||
simple_stmt ::= PASS:p {: RESULT = null; :}
|
||||
| expr:e {: RESULT = new ExprStmt(exleft, exright, e); :}
|
||||
| RETURN:r expr:e {: RESULT = new ReturnStmt(rxleft, exright, e); :}
|
||||
| RETURN {: RESULT = null; :}
|
||||
| RETURN:r {: RESULT = new ReturnStmt(rxleft, rxright, null); :}
|
||||
| opt_target:ot expr:e {: RESULT = new AssignStmt(getLeft(ot), exright, ot, e); :}
|
||||
;
|
||||
|
||||
@@ -451,7 +456,7 @@ pexpr ::= identifier:id {: RESULT = id; :}
|
||||
| pexpr:p1 MUL:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo, p2); :}
|
||||
| pexpr:p1 DIV:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo, p2); :}
|
||||
| pexpr:p1 MOD:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo, p2); :}
|
||||
| MINUS:m pexpr:p {: RESULT = new UnaryExpr(mxleft, pxright, m, p); :}
|
||||
| MINUS:m pexpr:p {: RESULT = new UnaryExpr(mxleft, pxright, m, p); :} %prec UMINUS
|
||||
;
|
||||
|
||||
expr_list ::= expr:e {: RESULT = single(e); :}
|
||||
|
||||
Reference in New Issue
Block a user