aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-11-16 20:28:38 +0100
committerTristan Gingold <tgingold@free.fr>2018-11-16 20:28:38 +0100
commit2be707f77a48aeb8213f1d9f37ee1dd34b4bdcee (patch)
tree2e3602c14a8684078e068810c81540b7f5471ae2
parent04867afa5d47443fcae1ab24bb648cca2244e671 (diff)
downloadghdl-2be707f77a48aeb8213f1d9f37ee1dd34b4bdcee.tar.gz
ghdl-2be707f77a48aeb8213f1d9f37ee1dd34b4bdcee.tar.bz2
ghdl-2be707f77a48aeb8213f1d9f37ee1dd34b4bdcee.zip
scanner: improve error message, detect EOF in extended identifiers.
-rw-r--r--src/vhdl/scanner.adb70
1 files changed, 44 insertions, 26 deletions
diff --git a/src/vhdl/scanner.adb b/src/vhdl/scanner.adb
index 9a2b488da..86c039bb2 100644
--- a/src/vhdl/scanner.adb
+++ b/src/vhdl/scanner.adb
@@ -450,7 +450,12 @@ package body Scanner is
Pos := Current_Context.Token_Pos + 1;
return;
end if;
- Error_Msg_Scan ("format effector not allowed in a string");
+ if C = CR or C = LF then
+ Error_Msg_Scan
+ ("string cannot be multi-line, use concatenation");
+ else
+ Error_Msg_Scan ("format effector not allowed in a string");
+ end if;
exit;
when Invalid =>
if C = Files_Map.EOT
@@ -1251,65 +1256,78 @@ package body Scanner is
-- LRM93 13.3.2
-- EXTENDED_IDENTIFIER ::= \ GRAPHIC_CHARACTER { GRAPHIC_CHARACTER } \
--
- -- Create an (extended) indentifier.
- -- Extended identifiers are stored as they appear (leading and tailing
- -- backslashes, doubling backslashes inside).
+ -- Create an (extended) indentifier.
+ -- Extended identifiers are stored as they appear (leading and tailing
+ -- backslashes, doubling backslashes inside).
procedure Scan_Extended_Identifier
is
use Name_Table;
Buffer : String (1 .. Max_Name_Length);
Len : Natural;
+ C : Character;
begin
- -- LRM93 13.3.2
- -- Moreover, every extended identifiers is distinct from any basic
- -- identifier.
- -- This is satisfied by storing '\' in the name table.
+ -- LRM93 13.3.2
+ -- Moreover, every extended identifiers is distinct from any basic
+ -- identifier.
+ -- GHDL: This is satisfied by storing '\' in the name table.
Len := 1;
Buffer (1) := '\';
loop
-- Next character.
Pos := Pos + 1;
+ C := Source (Pos);
- if Source (Pos) = '\' then
- -- LRM93 13.3.2
- -- If a backslash is to be used as one of the graphic characters
- -- of an extended literal, it must be doubled.
- -- LRM93 13.3.2
- -- (a doubled backslash couting as one character)
+ if C = '\' then
+ -- LRM93 13.3.2
+ -- If a backslash is to be used as one of the graphic characters
+ -- of an extended literal, it must be doubled.
+ -- LRM93 13.3.2
+ -- (a doubled backslash couting as one character)
Len := Len + 1;
Buffer (Len) := '\';
Pos := Pos + 1;
+ C := Source (Pos);
- exit when Source (Pos) /= '\';
+ exit when C /= '\';
end if;
- -- source (pos) is correct.
- case Characters_Kind (Source (Pos)) is
+ case Characters_Kind (C) is
when Format_Effector =>
Error_Msg_Scan ("format effector in extended identifier");
exit;
when Graphic_Character =>
null;
when Invalid =>
- Error_Msg_Scan ("invalid character in extended identifier");
+ if C = Files_Map.EOT
+ and then Pos >= Current_Context.File_Len
+ then
+ Error_Msg_Scan
+ ("extended identifier not terminated at end of file");
+ elsif C = LF or C = CR then
+ Error_Msg_Scan
+ ("extended identifier not terminated at end of line");
+ else
+ Error_Msg_Scan ("invalid character in extended identifier");
+ end if;
+ exit;
end case;
Len := Len + 1;
- -- LRM93 13.3.2
- -- Extended identifiers differing only in the use of corresponding
- -- upper and lower case letters are distinct.
- Buffer (Len) := Source (Pos);
+ -- LRM93 13.3.2
+ -- Extended identifiers differing only in the use of corresponding
+ -- upper and lower case letters are distinct.
+ Buffer (Len) := C;
end loop;
if Len <= 2 then
Error_Msg_Scan ("empty extended identifier is not allowed");
end if;
- -- LRM93 13.2
- -- At least one separator is required between an identifier or an
- -- abstract literal and an adjacent identifier or abstract literal.
- case Characters_Kind (Source (Pos)) is
+ -- LRM93 13.2
+ -- At least one separator is required between an identifier or an
+ -- abstract literal and an adjacent identifier or abstract literal.
+ case Characters_Kind (C) is
when Digit
| Upper_Case_Letter
| Lower_Case_Letter =>