Added cexpr

master
Sanjar Ahmadov 3 years ago
parent 7b2e1dab3f
commit 1c02aa84d8

@ -403,7 +403,7 @@ literal ::= NONE:n {: RESULT = new NoneLi
/* expr */
expr ::= pexpr:ce {: RESULT = ce; :}
expr ::= cexpr:ce {: RESULT = ce; :}
| NOT:n expr:exp {: RESULT = new UnaryExpr(nxleft, expxright, n, exp); :}
| expr:e1 AND:a expr:e2 {: RESULT = new BinaryExpr(e1xleft, e2xright, e1, a, e2); :}
| expr:e1 OR:o expr:e2 {: RESULT = new BinaryExpr(e1xleft, e2xright, e1, o, e2); :}
@ -412,29 +412,23 @@ expr ::= pexpr:ce {: RESULT = ce; :}
/* cexpr */
/*
cexpr ::= pexpr:pe {: RESULT = new Expr(pexleft, pexright); :}
| cmp_pexpr:cp {: RESULT = new Expr(cpxleft, cpxright); :}
cexpr ::= pexpr:pe {: RESULT = pe; :}
| pexpr:p1 comp_op:co cexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, co.value, p2); :}
;
cmp_pexpr ::= pexpr:p comp_op:co cmp_pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, co, p2); :}
| pexpr:p {: RESULT = new Expr(pxleft, pxright); :}
;
*/
/* pexpr */
pexpr ::= identifier:id {: RESULT = id; :}
| literal:l {: RESULT = l; :}
| LBR:lbr expr_list:l RBR:rbr {: RESULT = new ListExpr(lbrxleft, rbrxright, l); :}
| LPAR:lpar expr:e RPAR:rpar {: RESULT = e; :}
| LPAR:lpar expr:e RPAR:rpar {: RESULT = e; :}
| member_expr:m {: RESULT = m; :}
| index_expr:i {: RESULT = i; :}
| 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); :}
| pexpr:p1 bin_op:bo pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, bo.value, p2); :}
| MINUS:m pexpr:p {: RESULT = new UnaryExpr(mxleft, pxright, m, p); :}
| pexpr:p1 comp_op:co pexpr:p2 {: RESULT = new BinaryExpr(p1xleft, p2xright, p1, co.value, p2); :}
;
expr_list ::= expr:e {: RESULT = single(e); :}

Loading…
Cancel
Save