1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2002-2007, Free Software Foundation, Inc. --
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 --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with GNAT.Dynamic_Tables;
29 with Namet; use Namet;
30 with Types; use Types;
38 type Symbol_Data is record
39 Symbol : Name_Id := No_Name;
40 -- The symbol in lower case
42 Original : Name_Id := No_Name;
43 -- The symbol as originally given in the definition file or on
46 On_The_Command_Line : Boolean := False;
47 -- Set to True if symbol is defined on the command line.
48 -- Used to prevent replacement of command line symbols by definition
51 Is_A_String : Boolean := False;
52 -- Indicate if the value of the symbol has been specified as a string
53 -- or simply as a sequence of characters.
55 Value : String_Id := No_String;
56 -- The value of the symbol (string or sequence of characters)
60 True_Value : Symbol_Data :=
63 On_The_Command_Line => False,
67 type Symbol_Id is new Nat;
68 No_Symbol : constant Symbol_Id := 0;
70 package Symbol_Table is new GNAT.Dynamic_Tables
71 (Table_Component_Type => Symbol_Data,
72 Table_Index_Type => Symbol_Id,
75 Table_Increment => 100);
76 -- The table of all symbols
78 Mapping : Symbol_Table.Instance;
79 -- The mapping table of symbols to values used by procedure Parse_Def_File
82 function Index_Of (Symbol : Name_Id) return Symbol_Id;
83 -- Return the index in the Mapping table of Symbol.
84 -- Return No_Symbol if Symbol in not in the Mapping table.
86 -- Access to procedure types used by procedure Initialize below:
88 type Error_Msg_Proc is access procedure
89 (Msg : String; Flag_Location : Source_Ptr);
91 type Scan_Proc is access procedure;
93 type Set_Ignore_Errors_Proc is access procedure (To : Boolean);
95 type Put_Char_Proc is access procedure (C : Character);
97 type New_EOL_Proc is access procedure;
100 (Error_Msg : Error_Msg_Proc;
102 Set_Ignore_Errors : Set_Ignore_Errors_Proc;
103 Put_Char : Put_Char_Proc;
104 New_EOL : New_EOL_Proc);
106 procedure Parse_Def_File;
107 -- Parse the definition file. The definition file must have already been
108 -- loaded and the scanner initialized.
110 procedure Preprocess;
111 -- Preprocess the input file. The input file must have already been loaded
112 -- and the scanner initialized.
114 procedure Check_Command_Line_Symbol_Definition
115 (Definition : String;
116 Data : out Symbol_Data);
117 -- Check the validity of a command line definition <symbol>=<value>.
118 -- Return the symbol and its value in Data if the definition is valid,
119 -- fail if it is not valid.
121 procedure Change_Reserved_Keyword_To_Symbol
122 (All_Keywords : Boolean := False);
123 -- If Token is an Ada reserved word (other than IF, ELSIF, ELSE,
124 -- END, AND, OR, THEN when All_Keywords is False), change it to
125 -- Tok_Identifier with the corresponding Token_Name.
127 procedure List_Symbols (Foreword : String);
128 -- List the symbols used por preprocessing a file, with their values.
129 -- If Foreword is not empty, Output Foreword before the list.