From 23f2148948ae33495cae62ee5002cba89bc1da30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind?= Date: Sun, 13 Feb 2022 18:34:52 +0100 Subject: [PATCH] Added noassoc to if then and else --- exercises/02/vslc/src/parser.y | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exercises/02/vslc/src/parser.y b/exercises/02/vslc/src/parser.y index f72326e..e29cbad 100644 --- a/exercises/02/vslc/src/parser.y +++ b/exercises/02/vslc/src/parser.y @@ -11,7 +11,11 @@ %nonassoc UMINUS %right '~' +%nonassoc IF THEN +%nonassoc ELSE + %% + program: global_list { node_init(root = malloc(sizeof(node_t)), PROGRAM, NULL, 1, $1); @@ -94,8 +98,8 @@ declaration_list: declaration { node_init($$ = malloc(sizeof(node_t)), DECLARATION_LIST, NULL, 1, $1); } - | declaration_list ',' declaration { - node_init($$ = malloc(sizeof(node_t)), DECLARATION_LIST, NULL, 2, $1, $3); + | declaration_list declaration { + node_init($$ = malloc(sizeof(node_t)), DECLARATION_LIST, NULL, 2, $1, $2); } ;