aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-01-18 20:36:00 +0100
committerTristan Gingold <tgingold@free.fr>2018-01-18 20:36:00 +0100
commit22961e664b8316941624d11b87fa003d010d34cf (patch)
tree3d4c27292f126e9478918ab5eb4423f83e8e729c /src/vhdl
parent4262391b472e3c6c72071ebee0381b63195b44f6 (diff)
downloadghdl-22961e664b8316941624d11b87fa003d010d34cf.tar.gz
ghdl-22961e664b8316941624d11b87fa003d010d34cf.tar.bz2
ghdl-22961e664b8316941624d11b87fa003d010d34cf.zip
Convert_Identifier: don't use Nam_Buffer anymore.
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/scanner.adb28
-rw-r--r--src/vhdl/scanner.ads2
2 files changed, 16 insertions, 14 deletions
diff --git a/src/vhdl/scanner.adb b/src/vhdl/scanner.adb
index fdafdae27..ab4695b78 100644
--- a/src/vhdl/scanner.adb
+++ b/src/vhdl/scanner.adb
@@ -1297,7 +1297,7 @@ package body Scanner is
Current_Token := Tok_Identifier;
end Scan_Extended_Identifier;
- procedure Convert_Identifier
+ procedure Convert_Identifier (Str : in out String)
is
procedure Error_Bad is
begin
@@ -1311,36 +1311,38 @@ package body Scanner is
use Name_Table;
C : Character;
+ subtype Id_Subtype is String (1 .. Str'Length);
+ Id : Id_Subtype renames Str;
begin
- if Nam_Length = 0 then
+ if Id'Length = 0 then
Error_Msg_Option ("identifier required");
return;
end if;
- if Nam_Buffer (1) = '\' then
+ if Id (1) = '\' then
-- Extended identifier.
if Vhdl_Std = Vhdl_87 then
Error_Msg_Option ("extended identifiers not allowed in vhdl87");
return;
end if;
- if Nam_Length < 3 then
+ if Id'Length < 3 then
Error_Msg_Option ("extended identifier is too short");
return;
end if;
- if Nam_Buffer (Nam_Length) /= '\' then
+ if Id (Id'Last) /= '\' then
Error_Msg_Option ("extended identifier must finish with a '\'");
return;
end if;
- for I in 2 .. Nam_Length - 1 loop
- C := Nam_Buffer (I);
+ for I in 2 .. Id'Last - 1 loop
+ C := Id (I);
case Characters_Kind (C) is
when Format_Effector =>
Error_Msg_Option ("format effector in extended identifier");
return;
when Graphic_Character =>
if C = '\' then
- if Nam_Buffer (I + 1) /= '\'
+ if Id (I + 1) /= '\'
or else I = Nam_Length - 1
then
Error_Msg_Option ("anti-slash must be doubled "
@@ -1354,14 +1356,14 @@ package body Scanner is
end loop;
else
-- Identifier
- for I in 1 .. Nam_Length loop
- C := Nam_Buffer (I);
+ for I in 1 .. Id'Length loop
+ C := Id (I);
case Characters_Kind (C) is
when Upper_Case_Letter =>
if Vhdl_Std = Vhdl_87 and C > 'Z' then
Error_8bit;
end if;
- Nam_Buffer (I) := To_Lower_Map (C);
+ Id (I) := To_Lower_Map (C);
when Lower_Case_Letter | Digit =>
if Vhdl_Std = Vhdl_87 and C > 'z' then
Error_8bit;
@@ -1374,12 +1376,12 @@ package body Scanner is
("identifier cannot start with an underscore");
return;
end if;
- if Nam_Buffer (I - 1) = '_' then
+ if Id (I - 1) = '_' then
Error_Msg_Option
("two underscores can't be consecutive");
return;
end if;
- if I = Nam_Length then
+ if I = Id'Last then
Error_Msg_Option
("identifier cannot finish with an underscore");
return;
diff --git a/src/vhdl/scanner.ads b/src/vhdl/scanner.ads
index 05f45f663..610d63140 100644
--- a/src/vhdl/scanner.ads
+++ b/src/vhdl/scanner.ads
@@ -119,7 +119,7 @@ package Scanner is
-- given in the command line.
-- Errors are directly reported through error_msg_option.
-- Also, Vhdl_Std should be set.
- procedure Convert_Identifier;
+ procedure Convert_Identifier (Str : in out String);
-- Return TRUE iff C is a whitespace.
-- LRM93 13.2 Lexical elements, separators, and delimiters