diff options
author | Ondrej Ille <ondrej.ille@gmail.com> | 2021-04-03 01:44:51 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2021-04-03 20:29:38 +0200 |
commit | 494c9334c3cc365c44f4f21f959acf4e576a7814 (patch) | |
tree | 9629f13944b6dbe0da136a17a0a3fdeca719d112 /src | |
parent | a54112669f17ed9b4a041fc3fcd6548679c66708 (diff) | |
download | ghdl-494c9334c3cc365c44f4f21f959acf4e576a7814.tar.gz ghdl-494c9334c3cc365c44f4f21f959acf4e576a7814.tar.bz2 ghdl-494c9334c3cc365c44f4f21f959acf4e576a7814.zip |
src: Better reporting of missing parenthesis.
If multiple are missing, report only once and total missing count.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 6df41e2ba..6d45b0a20 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -85,6 +85,10 @@ package body Vhdl.Parse is -- Current number of open parenthesis (in expressions). Parenthesis_Depth : Natural := 0; + -- Missing parenthesis has been reported already. Flag used to + -- remember only first report + Parenthesis_Reported : Boolean := False; + -- Copy the current location into an iir. procedure Set_Location (Node : Iir) is begin @@ -513,6 +517,25 @@ package body Vhdl.Parse is end case; end Error_Variable_Location; + procedure Error_Missing_Parenthesis(Loc : Location_Type) is + begin + if not Parenthesis_Reported then + if Parenthesis_Depth > 1 then + Error_Msg_Parse + ("missing ')' for opening parenthesis at %l. " & + "Total missing parenthesis: " & + Integer'Image(Parenthesis_Depth), +Loc); + Parenthesis_Reported := True; + else + Error_Msg_Parse + ("missing ')' for opening parenthesis at %l. " , +Loc); + end if; + end if; + if Parenthesis_Depth = 1 then + Parenthesis_Reported := False; + end if; + end Error_Missing_Parenthesis; + -- Expect and scan ';' emit an error message using MSG if not present. procedure Scan_Semi_Colon (Msg : String) is begin @@ -5806,12 +5829,8 @@ package body Vhdl.Parse is | Tok_Generate | Tok_Loop => -- Surely a missing parenthesis. - -- FIXME: in case of multiple missing parenthesises, several - -- messages will be displayed - Error_Msg_Parse - ("missing ')' for opening parenthesis at %l", +Loc); + Error_Missing_Parenthesis(Loc); return Expr; - when others => -- Surely a parse error... null; |