annotate gcc/ada/scn.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S C N --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package contains the lexical analyzer routines. This is used by the
kono
parents:
diff changeset
27 -- compiler for scanning Ada source files.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 with Casing; use Casing;
kono
parents:
diff changeset
30 with Errout; use Errout;
kono
parents:
diff changeset
31 with Scng;
kono
parents:
diff changeset
32 with Style; -- use Style;
kono
parents:
diff changeset
33 with Types; use Types;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 package Scn is
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 procedure Initialize_Scanner
kono
parents:
diff changeset
38 (Unit : Unit_Number_Type;
kono
parents:
diff changeset
39 Index : Source_File_Index);
kono
parents:
diff changeset
40 -- Initialize lexical scanner for scanning a new file. The caller has
kono
parents:
diff changeset
41 -- completed the construction of the Units.Table entry for the specified
kono
parents:
diff changeset
42 -- Unit and Index references the corresponding source file. A special case
kono
parents:
diff changeset
43 -- is when Unit = No_Unit, and Index corresponds to the source index for
kono
parents:
diff changeset
44 -- reading the configuration pragma file.
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 function Determine_Token_Casing return Casing_Type;
kono
parents:
diff changeset
47 -- Determines the casing style of the current token, which is either a
kono
parents:
diff changeset
48 -- keyword or an identifier. See also package Casing.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Post_Scan;
kono
parents:
diff changeset
51 -- Create nodes for tokens: Char_Literal, Identifier, Real_Literal,
kono
parents:
diff changeset
52 -- Integer_Literal, String_Literal and Operator_Symbol.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Scan_Reserved_Identifier (Force_Msg : Boolean);
kono
parents:
diff changeset
55 -- This procedure is called to convert the current token, which the caller
kono
parents:
diff changeset
56 -- has checked is for a reserved word, to an equivalent identifier. This is
kono
parents:
diff changeset
57 -- of course only used in error situations where the parser can detect that
kono
parents:
diff changeset
58 -- a reserved word is being used as an identifier. An appropriate error
kono
parents:
diff changeset
59 -- message, pointing to the token, is also issued if either this is the
kono
parents:
diff changeset
60 -- first occurrence of misuse of this identifier, or if Force_Msg is True.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -------------
kono
parents:
diff changeset
63 -- Scanner --
kono
parents:
diff changeset
64 -------------
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 -- The scanner used by the compiler is an instantiation of the
kono
parents:
diff changeset
67 -- generic package Scng with routines appropriate to the compiler
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 package Scanner is new Scng
kono
parents:
diff changeset
70 (Post_Scan => Post_Scan,
kono
parents:
diff changeset
71 Error_Msg => Error_Msg,
kono
parents:
diff changeset
72 Error_Msg_S => Error_Msg_S,
kono
parents:
diff changeset
73 Error_Msg_SC => Error_Msg_SC,
kono
parents:
diff changeset
74 Error_Msg_SP => Error_Msg_SP,
kono
parents:
diff changeset
75 Style => Style.Style_Inst);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 procedure Scan renames Scanner.Scan;
kono
parents:
diff changeset
78 -- Scan scans out the next token, and advances the scan state accordingly
kono
parents:
diff changeset
79 -- (see package Scans for details). If the scan encounters an illegal
kono
parents:
diff changeset
80 -- token, then an error message is issued pointing to the bad character,
kono
parents:
diff changeset
81 -- and Scan returns a reasonable substitute token of some kind.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 end Scn;