2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / prep.ads
blob7e0c0ec62a0548fcf7eea0e339164852673b079d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R E P --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2002, Free Software Foundation, Inc. --
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 --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with GNAT.Dynamic_Tables;
29 with Types; use Types;
31 package Prep is
33 -----------------
34 -- Symbol Data --
35 -----------------
37 type Symbol_Data is record
38 Symbol : Name_Id := No_Name;
39 -- The symbol in lower case
41 Original : Name_Id := No_Name;
42 -- The symbol as originally given in the definition file or on
43 -- the command line.
45 On_The_Command_Line : Boolean := False;
46 -- Set to True if symbol is defined on the command line.
47 -- Used to prevent replacement of command line symbols by definition
48 -- file symbols.
50 Is_A_String : Boolean := False;
51 -- Indicate if the value of the symbol has been specified as a string
52 -- or simply as a sequence of characters.
54 Value : String_Id := No_String;
55 -- The value of the symbol (string or sequence of characters)
57 end record;
59 True_Value : Symbol_Data :=
60 (Symbol => No_Name,
61 Original => No_Name,
62 On_The_Command_Line => False,
63 Is_A_String => False,
64 Value => No_String);
66 type Symbol_Id is new Nat;
67 No_Symbol : constant Symbol_Id := 0;
69 package Symbol_Table is new GNAT.Dynamic_Tables
70 (Table_Component_Type => Symbol_Data,
71 Table_Index_Type => Symbol_Id,
72 Table_Low_Bound => 1,
73 Table_Initial => 10,
74 Table_Increment => 10);
75 -- The table of all symbols
77 Mapping : Symbol_Table.Instance;
78 -- The mapping table of symbols to values used by procedure Parse_Def_File
79 -- and Preprocess.
81 function Index_Of (Symbol : Name_Id) return Symbol_Id;
82 -- Return the index in the Mapping table of Symbol.
83 -- Return No_Symbol if Symbol in not in the Mapping table.
85 -- Access to procedure types used by procedure Initialize below:
87 type Error_Msg_Proc is access procedure
88 (Msg : String; Flag_Location : Source_Ptr);
90 type Scan_Proc is access procedure;
92 type Set_Ignore_Errors_Proc is access procedure (To : Boolean);
94 type Put_Char_Proc is access procedure (C : Character);
96 type New_EOL_Proc is access procedure;
98 procedure Initialize
99 (Error_Msg : Error_Msg_Proc;
100 Scan : Scan_Proc;
101 Set_Ignore_Errors : Set_Ignore_Errors_Proc;
102 Put_Char : Put_Char_Proc;
103 New_EOL : New_EOL_Proc);
105 procedure Parse_Def_File;
106 -- Parse the definition file. The definition file must have already been
107 -- loaded and the scanner initialized.
109 procedure Preprocess;
110 -- Preprocess the input file. The input file must have already been loaded
111 -- and the scanner initialized.
113 procedure Check_Command_Line_Symbol_Definition
114 (Definition : String;
115 Data : out Symbol_Data);
116 -- Check the validity of a command line definition <symbol>=<value>.
117 -- Return the symbol and its value in Data if the definition is valid,
118 -- fail if it is not valid.
120 procedure Change_Reserved_Keyword_To_Symbol
121 (All_Keywords : Boolean := False);
122 -- If Token is an Ada reserved word (other than IF, ELSIF, ELSE,
123 -- END, AND, OR, THEN when All_Keywords is False), change it to
124 -- Tok_Identifier with the corresponding Token_Name.
126 procedure List_Symbols (Foreword : String);
127 -- List the symbols used por preprocessing a file, with their values.
128 -- If Foreword is not empty, Output Foreword before the list.
130 end Prep;