aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pc.y18
1 files changed, 16 insertions, 2 deletions
diff --git a/pc.y b/pc.y
index a264286..8363428 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
@@ -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