added C like precedence for operators

This commit is contained in:
Sven Vogel 2024-05-14 19:20:58 +02:00
parent 3ea179b4a9
commit 32b964444a
1 changed files with 10 additions and 3 deletions

View File

@ -104,12 +104,19 @@
%token FunExtsupport %token FunExtsupport
/* Operator associativity */ /* Operator associativity */
/* Operators at lower line number have lower precedence */
/* Operators in same line have same precedence */
%right '=' %right '='
%left OpOr
%left OpXor
%left OpAnd
%left OpBitor
%left OpBitxor
%left OpBitand
%left OpEquals '<' '>'
%left '+' '-' %left '+' '-'
%left '*' '/' %left '*' '/'
%left OpEquals OpNot '<' '>' %left OpNot OpBitnot
%left OpAnd OpOr OpXor
%left OpBitand OpBitor OpBitxor OpBitnot
%% %%
program: program programbody {AST_push_node(root, $2);} program: program programbody {AST_push_node(root, $2);}