diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-30 11:50:12 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-10-30 11:50:12 +0000 |
commit | ec621b58c93dc8c0937740e823af1384dbeec8ec (patch) | |
tree | c4a85e3c12ef94392561f5d5ce3fd9901be49440 /gcc/ada/par.adb | |
parent | 7e28d8492b09447e84f92f546a013a4637b47610 (diff) | |
download | gcc-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.adb')
-rw-r--r-- | gcc/ada/par.adb | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index b5365332fb3..56629ef436f 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -26,7 +26,6 @@ with Atree; use Atree; with Casing; use Casing; -with Csets; use Csets; with Debug; use Debug; with Elists; use Elists; with Errout; use Errout; @@ -189,6 +188,73 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is -- that there is a missing body, but it seems more reasonable to let the -- later semantic checking discover this. + ---------------------------------------------------- + -- Handling of Reserved Words Used as Identifiers -- + ---------------------------------------------------- + + -- Note: throughout the parser, the terms reserved word and keyword + -- are used interchangably to refer to the same set of reserved + -- keywords (including until, protected, etc). + + -- If a reserved word is used in place of an identifier, the parser + -- where possible tries to recover gracefully. In particular, if the + -- keyword is clearly spelled using identifier casing, e.g. Until in + -- a source program using mixed case identifiers and lower case keywords, + -- then the keyword is treated as an identifier if it appears in a place + -- where an identifier is required. + + -- The situation is more complex if the keyword is spelled with normal + -- keyword casing. In this case, the parser is more reluctant to + -- consider it to be intended as an identifier, unless it has some + -- further confirmation. + + -- In the case of an identifier appearing in the identifier list of a + -- declaration, the appearence of a comma or colon right after the + -- keyword on the same line is taken as confirmation. For an enumeration + -- literal, a comma or right paren right after the identifier is also + -- treated as adequate confirmation. + + -- The following type is used in calls to Is_Reserved_Identifier and + -- also to P_Defining_Identifier and P_Identifier. The default for all + -- these functins is that reserved words in reserved word case are not + -- considered to be reserved identifiers. The Id_Check value indicates + -- tokens, which if they appear immediately after the identifier, are + -- taken as confirming that the use of an identifier was expected + + type Id_Check is + (None, + -- Default, no special token test + + C_Comma_Right_Paren, + -- Consider as identifier if followed by comma or right paren + + C_Comma_Colon, + -- Consider as identifier if followed by comma or colon + + C_Do, + -- Consider as identifier if followed by DO + + C_Dot, + -- Consider as identifier if followed by period + + C_Greater_Greater, + -- Consider as identifier if followed by >> + + C_In, + -- Consider as identifier if followed by IN + + C_Is, + -- Consider as identifier if followed by IS + + C_Left_Paren_Semicolon, + -- Consider as identifier if followed by left paren or semicolon + + C_Use, + -- Consider as identifier if followed by USE + + C_Vertical_Bar_Arrow); + -- Consider as identifier if followed by | or => + -------------------------------------------- -- Handling IS Used in Place of Semicolon -- -------------------------------------------- @@ -450,9 +516,12 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is -- List that is created. package Ch2 is - function P_Identifier return Node_Id; function P_Pragma return Node_Id; + function P_Identifier (C : Id_Check := None) return Node_Id; + -- Scans out an identifier. The parameter C determines the treatment + -- of reserved identifiers. See declaration of Id_Check for details. + function P_Pragmas_Opt return List_Id; -- This function scans for a sequence of pragmas in other than a -- declaration sequence or statement sequence context. All pragmas @@ -482,7 +551,6 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is function P_Basic_Declarative_Items return List_Id; function P_Constraint_Opt return Node_Id; function P_Declarative_Part return List_Id; - function P_Defining_Identifier return Node_Id; function P_Discrete_Choice_List return List_Id; function P_Discrete_Range return Node_Id; function P_Discrete_Subtype_Definition return Node_Id; @@ -503,6 +571,11 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is -- case where the source has a single declaration with multiple -- defining identifiers. + function P_Defining_Identifier (C : Id_Check := None) return Node_Id; + -- Scan out a defining identifier. The parameter C controls the + -- treatment of errors in case a reserved word is scanned. See the + -- declaration of this type for details. + function Init_Expr_Opt (P : Boolean := False) return Node_Id; -- If an initialization expression is present (:= expression), then -- it is scanned out and returned, otherwise Empty is returned if no @@ -908,10 +981,12 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is -- past it, otherwise the call has no effect at all. T may be any -- reserved word token, or comma, left or right paren, or semicolon. - function Is_Reserved_Identifier return Boolean; + function Is_Reserved_Identifier (C : Id_Check := None) return Boolean; -- Test if current token is a reserved identifier. This test is based -- on the token being a keyword and being spelled in typical identifier - -- style (i.e. starting with an upper case letter). + -- style (i.e. starting with an upper case letter). The parameter C + -- determines the special treatment if a reserved word is encountered + -- that has the normal casing of a reserved word. procedure Merge_Identifier (Prev : Node_Id; Nxt : Token_Type); -- Called when the previous token is an identifier (whose Token_Node |