aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-11-04 20:14:51 +0100
committerTristan Gingold <tgingold@free.fr>2020-11-04 20:14:51 +0100
commit31ca0d8a687f0b3cc5615407e2ee6160e4355baa (patch)
treeb642f182ad106f00882541bbedcece93c86ece30 /src
parentf0334b05fd993c0762d0c647236b7b6c5c42f4ca (diff)
downloadghdl-31ca0d8a687f0b3cc5615407e2ee6160e4355baa.tar.gz
ghdl-31ca0d8a687f0b3cc5615407e2ee6160e4355baa.tar.bz2
ghdl-31ca0d8a687f0b3cc5615407e2ee6160e4355baa.zip
vhdl-parse: improve error recovery on extra right parenthesis
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/vhdl-parse.adb28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb
index 1d981b841..b67545779 100644
--- a/src/vhdl/vhdl-parse.adb
+++ b/src/vhdl/vhdl-parse.adb
@@ -6607,6 +6607,24 @@ package body Vhdl.Parse is
return Res;
end Parse_Expression;
+ -- Like Parse_Expression, but assumed the expression is followed by a
+ -- reserved identifier. As a result, it will diagnoses extra parentheses.
+ function Parse_Expression_Keyword return Iir
+ is
+ Res : Iir;
+ begin
+ Res := Parse_Expression;
+
+ if Current_Token = Tok_Right_Paren then
+ Error_Msg_Parse ("extra ')' ignored");
+
+ -- Skip ')'.
+ Scan;
+ end if;
+
+ return Res;
+ end Parse_Expression_Keyword;
+
-- precond : next token
-- postcond: next token.
--
@@ -7138,14 +7156,10 @@ package body Vhdl.Parse is
Clause := Res;
loop
- Set_Condition (Clause, Parse_Expression);
+ Set_Condition (Clause, Parse_Expression_Keyword);
Then_Loc := Get_Token_Location;
- if Current_Token = Tok_Then then
- -- Eat 'then'.
- Scan;
- else
- Expect_Error (Tok_Then, "'then' is expected here");
- end if;
+ -- Eat 'then'.
+ Expect_Scan (Tok_Then, "'then' is expected here");
Set_Sequential_Statement_Chain
(Clause, Parse_Sequential_Statements (Res));