aboutsummaryrefslogtreecommitdiff
path: root/pc.y
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-29 21:30:48 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-29 21:35:19 -0400
commitd6b038578577f7c0f4eeb95e35e6a2113e6d9732 (patch)
tree68609b4f92b701a0d1363c4905d0929018d3923b /pc.y
parent82dc3cf8d980b010a1cf2e3ac1c438c1412a21f8 (diff)
parent4f66397e285f7742bdf5bfd9f723e10104486ce2 (diff)
Merge branch 'master' of git.tuckerevans.com:/srv/git/private/pascal_compiler
Fix white space at end of lines in Testing files
Diffstat (limited to 'pc.y')
-rw-r--r--pc.y18
1 files changed, 16 insertions, 2 deletions
diff --git a/pc.y b/pc.y
index 1f9e9f1..7e4ca78 100644
--- a/pc.y
+++ b/pc.y
@@ -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
@@ -296,9 +300,9 @@ statement
{
$$ = $1;
}
- |IF expr THEN statement ELSE statement
+ |ifelse
{
- $$ = mktree(IF, $2, mktree(THEN, $4, $6));
+ $$ = $1;
}
|WHILE expr DO statement
{
@@ -325,6 +329,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