diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-08 07:03:35 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-08 07:03:35 +0100 |
commit | 51e5905570340b44408cf6f82129130f363373b6 (patch) | |
tree | 2e2ba2e790db3bee8bb110aa7722c703d8c218cd /src/vhdl | |
parent | 7a09c4b1764e891f07ba6cfc36a5f3baa96156a6 (diff) | |
download | ghdl-51e5905570340b44408cf6f82129130f363373b6.tar.gz ghdl-51e5905570340b44408cf6f82129130f363373b6.tar.bz2 ghdl-51e5905570340b44408cf6f82129130f363373b6.zip |
parse: continue to parse after error in design unit.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/parse.adb | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb index 39c5ca922..a2b22045c 100644 --- a/src/vhdl/parse.adb +++ b/src/vhdl/parse.adb @@ -285,6 +285,32 @@ package body Parse is end loop; end Resync_To_End_Of_Declaration; + procedure Resync_To_Next_Unit is + begin + -- Resync. + loop + case Current_Token is + when Tok_Eof => + exit; + when Tok_Semi_Colon => + -- Skip ';'. + Scan; + exit; + when Tok_Library + | Tok_Use + | Tok_Architecture + | Tok_Entity + | Tok_Package + | Tok_Configuration + | Tok_Context => + -- Possible start of a new unit. + exit; + when others => + Scan; + end case; + end loop; + end Resync_To_Next_Unit; + procedure Error_Missing_Semi_Colon (Msg : String) is begin Error_Msg_Parse (Get_Prev_Location, "missing "";"" at end of " & Msg); @@ -319,29 +345,7 @@ package body Parse is Scan; else Error_Missing_Semi_Colon (Msg); - - -- Resync. - loop - case Current_Token is - when Tok_Eof => - exit; - when Tok_Semi_Colon => - -- Skip ';'. - Scan; - exit; - when Tok_Library - | Tok_Use - | Tok_Architecture - | Tok_Entity - | Tok_Package - | Tok_Configuration - | Tok_Context => - -- Possible start of a new unit. - exit; - when others => - Scan; - end case; - end loop; + Resync_To_Next_Unit; end if; end Scan_Semi_Colon_Unit; @@ -9711,11 +9715,6 @@ package body Parse is begin pragma Assert (Parenthesis_Depth = 0); - -- Read the first token. - if Current_Token = Tok_Eof then - return Null_Iir; - end if; - -- Create the design unit node. Res := Create_Iir (Iir_Kind_Design_Unit); Set_Location (Res); @@ -9741,10 +9740,12 @@ package body Parse is else Error_Empty; end if; - return Null_Iir; + Resync_To_Next_Unit; + return Res; when others => Error_Empty; - return Null_Iir; + Resync_To_Next_Unit; + return Res; end case; end if; @@ -9770,9 +9771,8 @@ package body Parse is Set_Location (Res); Last_Design := Null_Iir; - loop + while Current_Token /= Tok_Eof loop Design := Parse_Design_Unit; - exit when Design = Null_Iir; Set_Design_File (Design, Res); -- Append unit to the design file. |