Simple fixes for the errors.

master
bill 4 years ago
parent fbc6ae9dcf
commit ab6c72e690

@ -268,7 +268,7 @@ precedence nonassoc EQUAL, NEQ, LT, GT, LEQ, GEQ, IS;
precedence left PLUS, MINUS; precedence left PLUS, MINUS;
precedence left MUL, DIV, MOD; precedence left MUL, DIV, MOD;
precedence left DOT, COMMA, LBR, RBR; precedence left DOT, COMMA, LBR, RBR;
precedence left IF, ELSE; precedence right IF, ELSE;
/* The start symbol. */ /* The start symbol. */
start with program; start with program;
@ -315,12 +315,12 @@ class_body_defs ::= class_body_defs:defs var_def:vd {: RESULT = combine(de
/* fun_def */ /* fun_def */
fun_def ::= DEF:def identifier:id LPAR typed_vars:params RPAR ret_type:rt COLON NEWLINE INDENT fun_body_decs:fbd stmt_list:sl DEDENT fun_def ::= DEF:def identifier:id LPAR typed_vars:params RPAR ret_type:rt COLON:col NEWLINE INDENT fun_body_decs:fbd stmt_list:sl DEDENT
{: RESULT = new FuncDef(defxleft, getRight(sl), id, params, rt, fbd, sl); :} {: TypeAnnotation _rt = rt;if(rt.getLocation()[0] == -2) _rt = new ClassType( colxright, colxright, "<None>");RESULT = new FuncDef(defxleft, getRight(sl), id, params, _rt, fbd, sl); :}
; ;
ret_type ::= ARROW type:t {: RESULT= t; :} ret_type ::= ARROW type:t {: RESULT= t; :}
| {: RESULT= null; :} | {: RESULT= new ClassType(new ComplexSymbolFactory.Location(-2,-1), new ComplexSymbolFactory.Location(-1,-1),"<None>"); :}
; ;
typed_vars ::= typed_var:tv {: RESULT= single(tv); :} typed_vars ::= typed_var:tv {: RESULT= single(tv); :}
@ -427,13 +427,17 @@ pexpr ::= identifier:id {: RESULT = id; :}
| index_expr:i {: RESULT = i; :} | index_expr:i {: RESULT = i; :}
| member_expr:m LPAR expr_list:l RPAR:rpar {: RESULT = new MethodCallExpr(mxleft, rparxright, m, l); :} | member_expr:m LPAR expr_list:l RPAR:rpar {: RESULT = new MethodCallExpr(mxleft, rparxright, m, l); :}
| identifier:id LPAR expr_list:l RPAR:rpar {: RESULT = new CallExpr(idxleft, rparxright, id, l); :} | identifier:id LPAR expr_list:l RPAR:rpar {: RESULT = new CallExpr(idxleft, rparxright, id, l); :}
| pexpr:p1 bin_op:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo.value, p2); :} | pexpr:p1 PLUS:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo, p2); :}
| pexpr:p1 MINUS:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo, p2); :}
| 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); :}
; ;
expr_list ::= expr:e {: RESULT = single(e); :} expr_list ::= expr:e {: RESULT = single(e); :}
| expr_list:el COMMA expr:e {: RESULT = combine(el, e); :} | expr_list:el COMMA expr:e {: RESULT = combine(el, e); :}
| {: RESULT = null; :} | {: RESULT = new ArrayList<Expr>(); :}
; ;

Loading…
Cancel
Save