Added precedence

main
Øyvind Skaaden 2022-02-13 18:07:47 +01:00
parent 3a309781d3
commit f7d79724c3
1 changed files with 7 additions and 1 deletions

View File

@ -5,6 +5,12 @@
%token FUNC PRINT RETURN CONTINUE IF THEN ELSE WHILE DO OPENBLOCK CLOSEBLOCK
%token VAR NUMBER IDENTIFIER STRING
%left '|' '&' '^'
%left '+' '-'
%left '*' '/'
%nonassoc UMINUS
%right '~'
%%
program:
global_list {
@ -217,7 +223,7 @@ expression:
| expression '/' expression {
node_init($$ = malloc(sizeof(node_t)), EXPRESSION, strdup("/"), 2, $1, $3);
}
| '-' expression {
| '-' expression %prec UMINUS {
node_init($$ = malloc(sizeof(node_t)), EXPRESSION, strdup("-"), 1, $2);
}
| '~' expression {