Added precedence
parent
3a309781d3
commit
f7d79724c3
|
@ -5,6 +5,12 @@
|
||||||
%token FUNC PRINT RETURN CONTINUE IF THEN ELSE WHILE DO OPENBLOCK CLOSEBLOCK
|
%token FUNC PRINT RETURN CONTINUE IF THEN ELSE WHILE DO OPENBLOCK CLOSEBLOCK
|
||||||
%token VAR NUMBER IDENTIFIER STRING
|
%token VAR NUMBER IDENTIFIER STRING
|
||||||
|
|
||||||
|
%left '|' '&' '^'
|
||||||
|
%left '+' '-'
|
||||||
|
%left '*' '/'
|
||||||
|
%nonassoc UMINUS
|
||||||
|
%right '~'
|
||||||
|
|
||||||
%%
|
%%
|
||||||
program:
|
program:
|
||||||
global_list {
|
global_list {
|
||||||
|
@ -217,7 +223,7 @@ expression:
|
||||||
| expression '/' expression {
|
| expression '/' expression {
|
||||||
node_init($$ = malloc(sizeof(node_t)), EXPRESSION, strdup("/"), 2, $1, $3);
|
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);
|
node_init($$ = malloc(sizeof(node_t)), EXPRESSION, strdup("-"), 1, $2);
|
||||||
}
|
}
|
||||||
| '~' expression {
|
| '~' expression {
|
||||||
|
|
Loading…
Reference in New Issue