diff --git a/exercises/02/vslc/src/parser.y b/exercises/02/vslc/src/parser.y index e567c41..f72326e 100644 --- a/exercises/02/vslc/src/parser.y +++ b/exercises/02/vslc/src/parser.y @@ -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 {