|
|
@ -316,11 +316,11 @@ 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:col 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
|
|
|
|
{: 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); :}
|
|
|
|
{: TypeAnnotation _rt = rt;if((rt instanceof ClassType) && ((ClassType)rt).className == "<None>") _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= new ClassType(new ComplexSymbolFactory.Location(-2,-1), new ComplexSymbolFactory.Location(-1,-1),"<None>"); :}
|
|
|
|
| {: RESULT= new ClassType(null, null,"<None>"); :}
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
typed_vars ::= typed_var:tv {: RESULT= single(tv); :}
|
|
|
|
typed_vars ::= typed_var:tv {: RESULT= single(tv); :}
|
|
|
@ -440,17 +440,16 @@ expr_list ::= expr:e {: RESULT = single(e);
|
|
|
|
| {: RESULT = new ArrayList<Expr>(); :}
|
|
|
|
| {: RESULT = new ArrayList<Expr>(); :}
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* bin_op */ //We may still be able to use bin_op, so I left it here.
|
|
|
|
/* bin_op */
|
|
|
|
|
|
|
|
bin_op ::= PLUS:a {: RESULT = new StringLiteral(axleft, axright, "+"); :}
|
|
|
|
bin_op ::= PLUS:a {: RESULT = new StringLiteral(axleft, axright, "+"); :}
|
|
|
|
| MINUS:a {: RESULT = new StringLiteral(axleft, axright, "-"); :}
|
|
|
|
| MINUS:a {: RESULT = new StringLiteral(axleft, axright, "-"); :}
|
|
|
|
| MUL:a {: RESULT = new StringLiteral(axleft, axright, "*"); :}
|
|
|
|
| MUL:a {: RESULT = new StringLiteral(axleft, axright, "*"); :}
|
|
|
|
| DIV:a {: RESULT = new StringLiteral(axleft, axright, "/"); :}
|
|
|
|
| DIV:a {: RESULT = new StringLiteral(axleft, axright, "//"); :} //Section 2.6.3 in chocopy language reference
|
|
|
|
| MOD:a {: RESULT = new StringLiteral(axleft, axright, "%"); :}
|
|
|
|
| MOD:a {: RESULT = new StringLiteral(axleft, axright, "%"); :}
|
|
|
|
;
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* comp_op */
|
|
|
|
/* comp_op */ //this might also need some change in order not to break left associativity
|
|
|
|
comp_op ::= EQUAL:a {: RESULT = new StringLiteral(axleft, axright, "=="); :}
|
|
|
|
comp_op ::= EQUAL:a {: RESULT = new StringLiteral(axleft, axright, "=="); :}
|
|
|
|
| NEQ:a {: RESULT = new StringLiteral(axleft, axright, "!="); :}
|
|
|
|
| NEQ:a {: RESULT = new StringLiteral(axleft, axright, "!="); :}
|
|
|
|
| LEQ:a {: RESULT = new StringLiteral(axleft, axright, "<="); :}
|
|
|
|
| LEQ:a {: RESULT = new StringLiteral(axleft, axright, "<="); :}
|
|
|
|