]>
Commit | Line | Data |
---|---|---|
996ae0b0 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- S C N -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
5f3ab6fb | 9 | -- Copyright (C) 1992-2004 Free Software Foundation, Inc. -- |
996ae0b0 RK |
10 | -- -- |
11 | -- GNAT is free software; you can redistribute it and/or modify it under -- | |
12 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
13 | -- ware Foundation; either version 2, or (at your option) any later ver- -- | |
14 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | |
15 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
16 | -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | |
17 | -- for more details. You should have received a copy of the GNU General -- | |
18 | -- Public License distributed with GNAT; see file COPYING. If not, write -- | |
cb5fee25 KC |
19 | -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
20 | -- Boston, MA 02110-1301, USA. -- | |
996ae0b0 RK |
21 | -- -- |
22 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 23 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
996ae0b0 RK |
24 | -- -- |
25 | ------------------------------------------------------------------------------ | |
26 | ||
fbf5a39b AC |
27 | -- This package contains the lexical analyzer routines. This is used by the |
28 | -- compiler for scanning Ada source files. | |
996ae0b0 RK |
29 | |
30 | with Casing; use Casing; | |
fbf5a39b AC |
31 | with Errout; use Errout; |
32 | with Scng; | |
33 | with Style; use Style; | |
996ae0b0 RK |
34 | with Types; use Types; |
35 | ||
36 | package Scn is | |
37 | ||
38 | procedure Initialize_Scanner | |
39 | (Unit : Unit_Number_Type; | |
40 | Index : Source_File_Index); | |
41 | -- Initialize lexical scanner for scanning a new file. The caller has | |
42 | -- completed the construction of the Units.Table entry for the specified | |
43 | -- Unit and Index references the corresponding source file. A special | |
44 | -- case is when Unit = No_Unit_Number, and Index corresponds to the | |
45 | -- source index for reading the configuration pragma file. | |
46 | ||
fbf5a39b AC |
47 | function Determine_Token_Casing return Casing_Type; |
48 | -- Determines the casing style of the current token, which is | |
49 | -- either a keyword or an identifier. See also package Casing. | |
996ae0b0 | 50 | |
5f3ab6fb AC |
51 | procedure Obsolescent_Check (S : Source_Ptr); |
52 | -- Called to handle pragma restrictions check for usage of obsolescent | |
53 | -- character replacements during the scan. | |
54 | ||
fbf5a39b AC |
55 | procedure Post_Scan; |
56 | pragma Inline (Post_Scan); | |
57 | -- Create nodes for tokens: Char_Literal, Identifier, Real_Literal, | |
58 | -- Integer_Literal, String_Literal and Operator_Symbol. | |
996ae0b0 RK |
59 | |
60 | procedure Scan_Reserved_Identifier (Force_Msg : Boolean); | |
61 | -- This procedure is called to convert the current token, which the caller | |
62 | -- has checked is for a reserved word, to an equivalent identifier. This is | |
63 | -- of course only used in error situations where the parser can detect that | |
64 | -- a reserved word is being used as an identifier. An appropriate error | |
65 | -- message, pointing to the token, is also issued if either this is the | |
66 | -- first occurrence of misuse of this identifier, or if Force_Msg is True. | |
67 | ||
fbf5a39b AC |
68 | ------------- |
69 | -- Scanner -- | |
70 | ------------- | |
71 | ||
72 | -- The scanner used by the compiler is an instantiation of the | |
73 | -- generic package Scng with routines appropriate to the compiler | |
74 | ||
75 | package Scanner is new Scng | |
5f3ab6fb AC |
76 | (Post_Scan => Post_Scan, |
77 | Error_Msg => Error_Msg, | |
78 | Error_Msg_S => Error_Msg_S, | |
79 | Error_Msg_SC => Error_Msg_SC, | |
80 | Error_Msg_SP => Error_Msg_SP, | |
81 | Obsolescent_Check => Obsolescent_Check, | |
82 | Style => Style.Style_Inst); | |
fbf5a39b AC |
83 | |
84 | procedure Scan renames Scanner.Scan; | |
85 | -- Scan scans out the next token, and advances the scan state accordingly | |
86 | -- (see package Scans for details). If the scan encounters an illegal | |
87 | -- token, then an error message is issued pointing to the bad character, | |
88 | -- and Scan returns a reasonable substitute token of some kind. | |
996ae0b0 RK |
89 | |
90 | end Scn; |