diff options
Diffstat (limited to 'src/vhdl/parse.adb')
-rw-r--r-- | src/vhdl/parse.adb | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb index cb8537e..d3d6442 100644 --- a/src/vhdl/parse.adb +++ b/src/vhdl/parse.adb @@ -272,7 +272,7 @@ package body Parse is end if; end Parse_Signal_Kind; - -- precond : next token + -- precond : TO, DOWNTO -- postcond: next token -- -- Parse a range. @@ -285,59 +285,26 @@ package body Parse is -- [3.1] -- range ::= RANGE_attribute_name -- | simple_expression direction simple_expression - function Parse_Range_Expression (Left: Iir; Discrete: Boolean := False) - return Iir + function Parse_Range_Expression (Left : Iir) return Iir is Res : Iir; - Left1: Iir; begin - if Left /= Null_Iir then - Left1 := Left; - else - Left1 := Parse_Simple_Expression; - end if; + Res := Create_Iir (Iir_Kind_Range_Expression); + Set_Left_Limit (Res, Left); + Location_Copy (Res, Left); case Current_Token is when Tok_To => - Res := Create_Iir (Iir_Kind_Range_Expression); Set_Direction (Res, Iir_To); when Tok_Downto => - Res := Create_Iir (Iir_Kind_Range_Expression); Set_Direction (Res, Iir_Downto); - when Tok_Range => - if not Discrete then - Unexpected ("range definition"); - end if; - Scan; - if Current_Token = Tok_Box then - Unexpected ("range expression expected"); - Scan; - return Null_Iir; - end if; - Res := Parse_Range_Expression (Null_Iir, False); - if Res /= Null_Iir then - Set_Type (Res, Left1); - end if; - return Res; when others => - if Left1 = Null_Iir then - return Null_Iir; - end if; - if Is_Range_Attribute_Name (Left1) then - return Left1; - end if; - if Discrete - and then Get_Kind (Left1) in Iir_Kinds_Denoting_Name - then - return Left1; - end if; - Error_Msg_Parse ("'to' or 'downto' expected"); - return Null_Iir; + raise Internal_Error; end case; - Set_Left_Limit (Res, Left1); - Location_Copy (Res, Left1); + -- Skip TO or DOWNTO. Scan; + Set_Right_Limit (Res, Parse_Simple_Expression); return Res; end Parse_Range_Expression; @@ -2031,9 +1998,6 @@ package body Parse is Append_Element (El_List, El); Set_Element_Position (El, Pos); Pos := Pos + 1; - if First = Null_Iir then - First := El; - end if; -- Skip identifier Scan; |