aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/parse.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2016-06-30 19:53:05 +0200
committerTristan Gingold <tgingold@free.fr>2016-07-03 14:16:16 +0200
commit5bb5802ff639d413dbc9a56f2e3f5318bd2b0c1c (patch)
tree78a4b5fe721606c3155f6249ff09e2e1b627c21f /src/vhdl/parse.adb
parentf100e7c33b3064d92a46ef09936aebd899203d8e (diff)
downloadghdl-5bb5802ff639d413dbc9a56f2e3f5318bd2b0c1c.tar.gz
ghdl-5bb5802ff639d413dbc9a56f2e3f5318bd2b0c1c.tar.bz2
ghdl-5bb5802ff639d413dbc9a56f2e3f5318bd2b0c1c.zip
vhdl08: fix parse of elsif in generate.
Diffstat (limited to 'src/vhdl/parse.adb')
-rw-r--r--src/vhdl/parse.adb40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index bfe73eaec..21c440db4 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -6516,6 +6516,20 @@ package body Parse is
function Parse_Generate_Statement_Body (Parent : Iir; Label : Name_Id)
return Iir
is
+ function Is_Early_End return Boolean is
+ begin
+ case Current_Token is
+ when Tok_Elsif
+ | Tok_Else =>
+ if Get_Kind (Parent) = Iir_Kind_If_Generate_Statement then
+ return True;
+ end if;
+ when others =>
+ null;
+ end case;
+ return False;
+ end Is_Early_End;
+
Bod : Iir;
begin
Bod := Create_Iir (Iir_Kind_Generate_Statement_Body);
@@ -6579,15 +6593,10 @@ package body Parse is
Parse_Concurrent_Statements (Bod);
- case Current_Token is
- when Tok_Elsif
- | Tok_Else =>
- if Get_Kind (Parent) = Iir_Kind_If_Generate_Statement then
- return Bod;
- end if;
- when others =>
- null;
- end case;
+ -- Return now if no 'end' (and not expected).
+ if Is_Early_End then
+ return Bod;
+ end if;
Expect (Tok_End);
@@ -6600,6 +6609,11 @@ package body Parse is
Check_End_Name (Label, Bod);
Scan_Semi_Colon ("generate statement body");
+ -- Return now if no 'end' (and not expected).
+ if Is_Early_End then
+ return Bod;
+ end if;
+
Expect (Tok_End);
-- Skip 'end'
@@ -6761,12 +6775,20 @@ package body Parse is
Set_Generate_Statement_Body (Clause, Bod);
+ -- Append clause to the generate statement.
if Last /= Null_Iir then
Set_Generate_Else_Clause (Last, Clause);
end if;
Last := Clause;
exit when Current_Token /= Tok_Elsif;
+
+ -- Create new alternative.
+ Clause := Create_Iir (Iir_Kind_If_Generate_Statement);
+ Set_Location (Clause, Loc);
+
+ -- Skip 'elsif'
+ Scan;
end loop;
if Current_Token = Tok_Else then