diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-25 19:41:36 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-25 19:41:36 -0400 |
commit | 75b7f9b97d9fc1186f7864f46c5e5d383432cfb7 (patch) | |
tree | 6c002a8203495b1cd011d945cb0774c1162e4ccd | |
parent | 944512372b71c0a03639264896e791d80e3b0143 (diff) |
Fix dangling else
-rw-r--r-- | pc.y | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -81,6 +81,10 @@ extern scope *cur_scope; %type <tval> opt_statements %type <tval> proc_statement +%type <tval> ifelse +%nonassoc THEN +%nonassoc ELSE + %type <tval> var %type <tval> type %type <ival> standard_type @@ -292,9 +296,9 @@ statement { $$ = $1; } - |IF expr THEN statement ELSE statement + |ifelse { - $$ = mktree(IF, $2, mktree(THEN, $4, $6)); + $$ = $1; } |WHILE expr DO statement { @@ -321,6 +325,16 @@ statement $$ = $1; } ; +ifelse + :IF expr THEN statement + { + $$ = mktree(IF, $2, mktree(THEN, $4, NULL)); + } + |IF expr THEN statement ELSE statement + { + $$ = mktree(IF, $2, mktree(THEN, $4, $6)); + } +; TD :TO |