added rules for operators

This commit is contained in:
Sven Vogel 2024-04-29 12:39:44 +02:00
parent 897de1b8e1
commit 7547331705
1 changed files with 30 additions and 1 deletions

View File

@ -55,6 +55,13 @@
%token FunLineno
%token FunExtsupport
/* Operator associativity */
%right '='
%left '+' '-' '*' '/'
%left OpEquals OpNot
%left OpAnd OpOr OpXor
%left OpBitand OpBitor OpBitxor OpBitnot
%%
program: assign
| definition;
@ -63,7 +70,8 @@ expr: ValFloat
| ValInt
| ValMultistr
| ValStr
| Ident;
| Ident
| operation;
assign: Ident '=' expr { DEBUG("Assignment"); };
@ -89,7 +97,28 @@ type: sign scale Ident
| sign scale KeyInt
| sign scale KeyFloat;
operation: oparith
| oplogic
| opbool
| opbit;
oparith: expr '+' expr
| expr '-' expr
| expr '*' expr
| expr '/' expr
| '-' expr %prec '*';
oplogic: expr OpEquals expr;
opbool: expr OpAnd expr
| expr OpOr expr
| expr OpXor expr
| OpNot expr %prec OpAnd;
opbit: expr OpBitand expr
| expr OpBitor expr
| expr OpBitxor expr
| OpBitnot expr %prec OpBitand;
%%