summaryrefslogtreecommitdiff
path: root/gcc/ada/par-util.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-30 11:50:12 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-30 11:50:12 +0000
commitec621b58c93dc8c0937740e823af1384dbeec8ec (patch)
treec4a85e3c12ef94392561f5d5ce3fd9901be49440 /gcc/ada/par-util.adb
parent7e28d8492b09447e84f92f546a013a4637b47610 (diff)
downloadgcc-ec621b58c93dc8c0937740e823af1384dbeec8ec.tar.gz
* 3vtrasym.adb:
Demangle Ada symbols returned by TBK$SYMBOLIZE. Correctly align line numbers when symbol name is too long. * g-signal.ads, g-signal.adb: New files * impunit.adb: (Non_Imp_File_Names): Added "g-signal" * Makefile.rtl: Introduce GNAT.Signals * freeze.adb: Minor reformatting * lib-writ.adb (Write_ALI): Never write ali file if -gnats is specified * par.adb, par-ch12.adb, par-ch13.adb, par-ch2.adb, par-ch3.adb, par-ch5.adb, par-ch6.adb, par-ch9.adb, par-util.adb: New handling of Id_Check parameter to improve recognition of keywords used as identifiers. Update copyright notice to include 2003 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73083 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/par-util.adb')
-rw-r--r--gcc/ada/par-util.adb87
1 files changed, 78 insertions, 9 deletions
diff --git a/gcc/ada/par-util.adb b/gcc/ada/par-util.adb
index d7e2e15e33a..d23269ea88d 100644
--- a/gcc/ada/par-util.adb
+++ b/gcc/ada/par-util.adb
@@ -24,6 +24,7 @@
-- --
------------------------------------------------------------------------------
+with Csets; use Csets;
with Uintp; use Uintp;
with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
@@ -419,7 +420,7 @@ package body Util is
-- Is_Reserved_Identifier --
----------------------------
- function Is_Reserved_Identifier return Boolean is
+ function Is_Reserved_Identifier (C : Id_Check := None) return Boolean is
begin
if not Is_Reserved_Keyword (Token) then
return False;
@@ -438,20 +439,88 @@ package body Util is
-- keyword casing, then we return False, since it is pretty
-- clearly intended to be a keyword.
- if Ident_Casing /= Unknown
- and then Key_Casing /= Unknown
- and then Ident_Casing /= Key_Casing
- and then Determine_Token_Casing = Key_Casing
+ if Ident_Casing = Unknown
+ or else Key_Casing = Unknown
+ or else Ident_Casing = Key_Casing
+ or else Determine_Token_Casing /= Key_Casing
then
- return False;
+ return True;
- -- Otherwise assume that an identifier was intended
+ -- Here we have a keyword written clearly with keyword casing.
+ -- In default mode, we would not be willing to consider this as
+ -- a reserved identifier, but if C is set, we may still accept it
- else
- return True;
+ elsif C /= None then
+ declare
+ Scan_State : Saved_Scan_State;
+ OK_Next_Tok : Boolean;
+
+ begin
+ Save_Scan_State (Scan_State);
+ Scan;
+
+ if Token_Is_At_Start_Of_Line then
+ return False;
+ end if;
+
+ case C is
+ when None =>
+ raise Program_Error;
+
+ when C_Comma_Right_Paren =>
+ OK_Next_Tok :=
+ Token = Tok_Comma or else Token = Tok_Right_Paren;
+
+ when C_Comma_Colon =>
+ OK_Next_Tok :=
+ Token = Tok_Comma or else Token = Tok_Colon;
+
+ when C_Do =>
+ OK_Next_Tok :=
+ Token = Tok_Do;
+
+ when C_Dot =>
+ OK_Next_Tok :=
+ Token = Tok_Dot;
+
+ when C_Greater_Greater =>
+ OK_Next_Tok :=
+ Token = Tok_Greater_Greater;
+
+ when C_In =>
+ OK_Next_Tok :=
+ Token = Tok_In;
+
+ when C_Is =>
+ OK_Next_Tok :=
+ Token = Tok_Is;
+
+ when C_Left_Paren_Semicolon =>
+ OK_Next_Tok :=
+ Token = Tok_Left_Paren or else Token = Tok_Semicolon;
+
+ when C_Use =>
+ OK_Next_Tok :=
+ Token = Tok_Use;
+
+ when C_Vertical_Bar_Arrow =>
+ OK_Next_Tok :=
+ Token = Tok_Vertical_Bar or else Token = Tok_Arrow;
+ end case;
+
+ Restore_Scan_State (Scan_State);
+
+ if OK_Next_Tok then
+ return True;
+ end if;
+ end;
end if;
end;
end if;
+
+ -- If we fall through it is not a reserved identifier
+
+ return False;
end Is_Reserved_Identifier;
----------------------