From 32b964444a32db659f1fc51f5c6154092f66b2e7 Mon Sep 17 00:00:00 2001 From: servostar Date: Tue, 14 May 2024 19:20:58 +0200 Subject: [PATCH] added C like precedence for operators --- src/yacc/parser.y | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/yacc/parser.y b/src/yacc/parser.y index 9224fb4..ee219e9 100644 --- a/src/yacc/parser.y +++ b/src/yacc/parser.y @@ -104,12 +104,19 @@ %token FunExtsupport /* Operator associativity */ +/* Operators at lower line number have lower precedence */ +/* Operators in same line have same precedence */ %right '=' +%left OpOr +%left OpXor +%left OpAnd +%left OpBitor +%left OpBitxor +%left OpBitand +%left OpEquals '<' '>' %left '+' '-' %left '*' '/' -%left OpEquals OpNot '<' '>' -%left OpAnd OpOr OpXor -%left OpBitand OpBitor OpBitxor OpBitnot +%left OpNot OpBitnot %% program: program programbody {AST_push_node(root, $2);}