aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/parse.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/parse.adb')
-rw-r--r--src/vhdl/parse.adb39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index 7c840de4f..637e404fa 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -4754,7 +4754,8 @@ package body Parse is
-- choices ::= choice { | choice }
--
-- Leave tok_double_arrow as current token.
- function Parse_Choices (Expr: Iir; First_Loc : Location_Type) return Iir
+ function Parse_Choices
+ (Expr: Iir; First_Loc : Location_Type; Pos : in out Int32) return Iir
is
First, Last : Iir;
A_Choice: Iir;
@@ -4766,6 +4767,8 @@ package body Parse is
Loc := First_Loc;
loop
A_Choice := Parse_A_Choice (Expr1, Loc);
+ Set_Choice_Position (A_Choice, Pos);
+ Pos := Pos + 1;
if First /= Null_Iir then
Set_Same_Alternative_Flag (A_Choice, True);
@@ -4806,6 +4809,7 @@ package body Parse is
Last : Iir;
Assoc: Iir;
Loc, Right_Loc : Location_Type;
+ Pos : Int32;
begin
Loc := Get_Token_Location;
@@ -4869,9 +4873,12 @@ package body Parse is
Res := Create_Iir (Iir_Kind_Aggregate);
Set_Location (Res, Loc);
Build_Init (Last);
+ Pos := 0;
loop
if Current_Token = Tok_Others then
Assoc := Parse_A_Choice (Null_Iir, Loc);
+ Set_Choice_Position (Assoc, Pos);
+ Pos := Pos + 1;
Expect (Tok_Double_Arrow);
-- Eat '=>'
@@ -4892,8 +4899,10 @@ package body Parse is
| Tok_Right_Paren =>
Assoc := Create_Iir (Iir_Kind_Choice_By_None);
Set_Location (Assoc, Loc);
+ Set_Choice_Position (Assoc, Pos);
+ Pos := Pos + 1;
when others =>
- Assoc := Parse_Choices (Expr, Loc);
+ Assoc := Parse_Choices (Expr, Loc, Pos);
Expect (Tok_Double_Arrow);
-- Eat '=>'.
@@ -5822,6 +5831,7 @@ package body Parse is
Target : Iir;
Last : Iir;
When_Loc : Location_Type;
+ Pos : Int32;
begin
Scan; -- accept 'with' token.
Res := Create_Iir (Iir_Kind_Concurrent_Selected_Signal_Assignment);
@@ -5842,6 +5852,7 @@ package body Parse is
Parse_Options (Res);
Build_Init (Last);
+ Pos := 0;
loop
Wf_Chain := Parse_Waveform;
Expect (Tok_When, "'when' expected after waveform");
@@ -5850,7 +5861,7 @@ package body Parse is
-- Eat 'when'.
Scan;
- Assoc := Parse_Choices (Null_Iir, When_Loc);
+ Assoc := Parse_Choices (Null_Iir, When_Loc, Pos);
Set_Associated_Chain (Assoc, Wf_Chain);
Append_Subchain (Last, Res, Assoc);
exit when Current_Token = Tok_Semi_Colon;
@@ -6363,6 +6374,7 @@ package body Parse is
Assoc: Iir;
Last_Assoc : Iir;
When_Loc : Location_Type;
+ Pos : Int32;
begin
Stmt := Create_Iir (Iir_Kind_Case_Statement);
Set_Label (Stmt, Label);
@@ -6382,6 +6394,7 @@ package body Parse is
end if;
Build_Init (Last_Assoc);
+ Pos := 0;
while Current_Token /= Tok_End loop
Expect (Tok_When);
When_Loc := Get_Token_Location;
@@ -6393,8 +6406,10 @@ package body Parse is
Error_Msg_Parse ("missing expression in alternative");
Assoc := Create_Iir (Iir_Kind_Choice_By_Expression);
Set_Location (Assoc, When_Loc);
+ Set_Choice_Position (Assoc, Pos);
+ Pos := Pos + 1;
else
- Assoc := Parse_Choices (Null_Iir, When_Loc);
+ Assoc := Parse_Choices (Null_Iir, When_Loc, Pos);
end if;
-- Skip '=>'.
@@ -7836,12 +7851,12 @@ package body Parse is
-- case_generate_alternative ::=
-- WHEN [ /alternative/_label : ] choices =>
-- generate_statement_body
- function Parse_Case_Generate_Alternative (Parent : Iir) return Iir
+ procedure Parse_Case_Generate_Alternative
+ (Parent : Iir; Assoc : out Iir; Pos : in out Int32)
is
Loc : Location_Type;
Alt_Label : Name_Id;
Bod : Iir;
- Assoc : Iir;
Expr : Iir;
End_Loc : Location_Type;
begin
@@ -7856,9 +7871,11 @@ package body Parse is
Error_Msg_Parse ("missing expression in alternative");
Assoc := Create_Iir (Iir_Kind_Choice_By_Expression);
Set_Location (Assoc);
+ Set_Choice_Position (Assoc, Pos);
+ Pos := Pos + 1;
elsif Current_Token = Tok_Others then
-- 'others' is not an expression!
- Assoc := Parse_Choices (Null_Iir, Loc);
+ Assoc := Parse_Choices (Null_Iir, Loc, Pos);
else
Expr := Parse_Expression;
@@ -7879,7 +7896,7 @@ package body Parse is
Scan;
end if;
- Assoc := Parse_Choices (Expr, Loc);
+ Assoc := Parse_Choices (Expr, Loc, Pos);
end if;
-- Set location of label (if any, for xref) or location of 'when'.
@@ -7895,8 +7912,6 @@ package body Parse is
-- Set location on the label, for xrefs.
Set_Location (Bod, Loc);
end if;
-
- return Assoc;
end Parse_Case_Generate_Alternative;
-- precond : CASE
@@ -7915,6 +7930,7 @@ package body Parse is
Res : Iir;
Alt : Iir;
Last_Alt : Iir;
+ Pos : Int32;
begin
if Label = Null_Identifier then
Error_Msg_Parse ("a generate statement must have a label");
@@ -7938,8 +7954,9 @@ package body Parse is
end if;
Last_Alt := Null_Iir;
+ Pos := 0;
while Current_Token = Tok_When loop
- Alt := Parse_Case_Generate_Alternative (Res);
+ Parse_Case_Generate_Alternative (Res, Alt, Pos);
if Last_Alt = Null_Iir then
Set_Case_Statement_Alternative_Chain (Res, Alt);
else