aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/parse.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-11-26 20:19:50 +0100
committerTristan Gingold <tgingold@free.fr>2018-11-26 20:19:50 +0100
commit5123e676258c6fa938cedf67427c92bee6281f91 (patch)
tree3ec254d0e7ad345d523bb79eb54dca5184cd355b /src/vhdl/parse.adb
parent44404214d370d226428e315da946d41ccf141507 (diff)
downloadghdl-5123e676258c6fa938cedf67427c92bee6281f91.tar.gz
ghdl-5123e676258c6fa938cedf67427c92bee6281f91.tar.bz2
ghdl-5123e676258c6fa938cedf67427c92bee6281f91.zip
parse: strenghten.
Diffstat (limited to 'src/vhdl/parse.adb')
-rw-r--r--src/vhdl/parse.adb33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index 61b563498..77fd71604 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -2156,7 +2156,7 @@ package body Parse is
Append (Last, Res, Unit);
-- Parse secondary units.
- while Current_Token /= Tok_End loop
+ while Current_Token = Tok_Identifier loop
Unit := Create_Iir (Iir_Kind_Unit_Declaration);
Set_Location (Unit);
Set_Parent (Unit, Parent);
@@ -2170,29 +2170,30 @@ package body Parse is
Multiplier := Parse_Primary;
Set_Physical_Literal (Unit, Multiplier);
- case Get_Kind (Multiplier) is
- when Iir_Kind_Simple_Name
- | Iir_Kind_Selected_Name
- | Iir_Kind_Physical_Int_Literal =>
- null;
- when Iir_Kind_Physical_Fp_Literal =>
- Error_Msg_Parse
- ("secondary units may only be defined with integer literals");
- when others =>
- Error_Msg_Parse ("a physical literal is expected here");
- end case;
+ if Multiplier /= Null_Iir then
+ case Get_Kind (Multiplier) is
+ when Iir_Kind_Simple_Name
+ | Iir_Kind_Selected_Name
+ | Iir_Kind_Physical_Int_Literal =>
+ null;
+ when Iir_Kind_Physical_Fp_Literal =>
+ Error_Msg_Parse
+ ("secondary units may only be defined by an integer");
+ when others =>
+ Error_Msg_Parse ("a physical literal is expected here");
+ end case;
+ end if;
Append (Last, Res, Unit);
Scan_Semi_Colon ("secondary unit");
end loop;
-- Skip 'end'.
- Scan;
+ Expect_Scan (Tok_End);
- Expect (Tok_Units);
+ -- Skip 'units'.
+ Expect_Scan (Tok_Units);
Set_End_Has_Reserved_Id (Res, True);
- -- Skip 'units'.
- Scan;
return Res;
end Parse_Physical_Type_Definition;