Merge pull request #45 from Servostar/43-add-parser-rule-for-operators
added rules for operators
This commit is contained in:
commit
55caa37ba7
|
@ -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: statement;
|
||||
|
||||
|
@ -63,7 +70,8 @@ expr: ValFloat
|
|||
| ValInt
|
||||
| ValMultistr
|
||||
| ValStr
|
||||
| Ident;
|
||||
| Ident
|
||||
| operation;
|
||||
|
||||
statement: assign
|
||||
| decl
|
||||
|
@ -93,6 +101,30 @@ 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
|
||||
| expr '<' expr
|
||||
| expr '>' 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;
|
||||
%%
|
||||
|
||||
int yyerror(char *s) {
|
||||
|
|
Loading…
Reference in New Issue