annotate gcc/ada/prep.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 -- P R E P --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2002-2018, 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 with GNAT.Dynamic_Tables;
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Namet; use Namet;
kono
parents:
diff changeset
29 with Types; use Types;
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 package Prep is
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -----------------
kono
parents:
diff changeset
34 -- Symbol Data --
kono
parents:
diff changeset
35 -----------------
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 type Symbol_Data is record
kono
parents:
diff changeset
38 Symbol : Name_Id := No_Name;
kono
parents:
diff changeset
39 -- The symbol in lower case
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 Original : Name_Id := No_Name;
kono
parents:
diff changeset
42 -- The symbol as originally given in the definition file or on
kono
parents:
diff changeset
43 -- the command line.
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 On_The_Command_Line : Boolean := False;
kono
parents:
diff changeset
46 -- Set to True if symbol is defined on the command line.
kono
parents:
diff changeset
47 -- Used to prevent replacement of command line symbols by definition
kono
parents:
diff changeset
48 -- file symbols.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 Is_A_String : Boolean := False;
kono
parents:
diff changeset
51 -- Indicate if the value of the symbol has been specified as a string
kono
parents:
diff changeset
52 -- or simply as a sequence of characters.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 Value : String_Id := No_String;
kono
parents:
diff changeset
55 -- The value of the symbol (string or sequence of characters)
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 end record;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 True_Value : Symbol_Data :=
kono
parents:
diff changeset
60 (Symbol => No_Name,
kono
parents:
diff changeset
61 Original => No_Name,
kono
parents:
diff changeset
62 On_The_Command_Line => False,
kono
parents:
diff changeset
63 Is_A_String => False,
kono
parents:
diff changeset
64 Value => No_String);
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 type Symbol_Id is new Nat;
kono
parents:
diff changeset
67 No_Symbol : constant Symbol_Id := 0;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 package Symbol_Table is new GNAT.Dynamic_Tables
kono
parents:
diff changeset
70 (Table_Component_Type => Symbol_Data,
kono
parents:
diff changeset
71 Table_Index_Type => Symbol_Id,
kono
parents:
diff changeset
72 Table_Low_Bound => 1,
kono
parents:
diff changeset
73 Table_Initial => 10,
kono
parents:
diff changeset
74 Table_Increment => 100);
kono
parents:
diff changeset
75 -- The table of all symbols
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 Mapping : Symbol_Table.Instance;
kono
parents:
diff changeset
78 -- The mapping table of symbols to values used by procedure Parse_Def_File
kono
parents:
diff changeset
79 -- and Preprocess.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 function Index_Of (Symbol : Name_Id) return Symbol_Id;
kono
parents:
diff changeset
82 -- Return the index in the Mapping table of Symbol.
kono
parents:
diff changeset
83 -- Return No_Symbol if Symbol in not in the Mapping table.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 -- Access to procedure types used by procedure Initialize below:
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 type Error_Msg_Proc is access procedure
kono
parents:
diff changeset
88 (Msg : String; Flag_Location : Source_Ptr);
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 type Scan_Proc is access procedure;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 type Set_Ignore_Errors_Proc is access procedure (To : Boolean);
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 type Put_Char_Proc is access procedure (C : Character);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 type New_EOL_Proc is access procedure;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Initialize;
kono
parents:
diff changeset
99 -- Initialize the preprocessor's global structures
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 procedure Setup_Hooks
kono
parents:
diff changeset
102 (Error_Msg : Error_Msg_Proc;
kono
parents:
diff changeset
103 Scan : Scan_Proc;
kono
parents:
diff changeset
104 Set_Ignore_Errors : Set_Ignore_Errors_Proc;
kono
parents:
diff changeset
105 Put_Char : Put_Char_Proc;
kono
parents:
diff changeset
106 New_EOL : New_EOL_Proc);
kono
parents:
diff changeset
107 -- Set the i/o hooks used by the preprocessor
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Parse_Def_File;
kono
parents:
diff changeset
110 -- Parse the definition file. The definition file must have already been
kono
parents:
diff changeset
111 -- loaded and the scanner initialized.
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Preprocess (Source_Modified : out Boolean);
kono
parents:
diff changeset
114 -- Preprocess the input file. The input file must have already been loaded
kono
parents:
diff changeset
115 -- and the scanner initialized. Source_Modified is set to True iff the
kono
parents:
diff changeset
116 -- preprocessor modified the source text.
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Check_Command_Line_Symbol_Definition
kono
parents:
diff changeset
119 (Definition : String;
kono
parents:
diff changeset
120 Data : out Symbol_Data);
kono
parents:
diff changeset
121 -- Check the validity of a command line definition <symbol>=<value>.
kono
parents:
diff changeset
122 -- Return the symbol and its value in Data if the definition is valid,
kono
parents:
diff changeset
123 -- fail if it is not valid.
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 procedure Change_Reserved_Keyword_To_Symbol
kono
parents:
diff changeset
126 (All_Keywords : Boolean := False);
kono
parents:
diff changeset
127 -- If Token is an Ada reserved word (other than IF, ELSIF, ELSE,
kono
parents:
diff changeset
128 -- END, AND, OR, THEN when All_Keywords is False), change it to
kono
parents:
diff changeset
129 -- Tok_Identifier with the corresponding Token_Name.
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 procedure List_Symbols (Foreword : String);
kono
parents:
diff changeset
132 -- List the symbols used for preprocessing a file, with their values.
kono
parents:
diff changeset
133 -- If Foreword is not empty, Output Foreword before the list.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 end Prep;