From 4cd3062255ea9e6376a554cdcf4d152112177b96 Mon Sep 17 00:00:00 2001 From: Sanjar Ahmadov Date: Wed, 17 Feb 2021 14:44:11 -0500 Subject: [PATCH] Added precedences --- src/main/cup/chocopy/pa1/ChocoPy.cup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/cup/chocopy/pa1/ChocoPy.cup b/src/main/cup/chocopy/pa1/ChocoPy.cup index c1b8605..f6abdda 100644 --- a/src/main/cup/chocopy/pa1/ChocoPy.cup +++ b/src/main/cup/chocopy/pa1/ChocoPy.cup @@ -213,7 +213,6 @@ terminal String RBR; terminal String ARROW; terminal String IS; - /* Returned by the lexer for erroneous tokens. Since it does not appear in * the grammar, it indicates a syntax error. */ terminal UNRECOGNIZED; @@ -231,7 +230,13 @@ non terminal Expr expr, binary_expr; /* Precedences (lowest to highest) for resolving what would otherwise be * ambiguities in the form of shift/reduce conflicts.. */ -precedence left PLUS; +precedence left OR; +precedence left AND; +precedence left NOT; +precedence nonassoc EQUAL, NEQ, LT, GT, LEQ, GEQ, IS; +precedence left PLUS, MINUS; +precedence left MUL, DIV, MOD; +precedence left DOT, COMMA, LBR, RBR; /* The start symbol. */ start with program;