OSDN Git Service

2007-08-14 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / prep.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                 P R E P                                  --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 2002-2007, 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,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, 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 ------------------------------------------------------------------------------
26
27 with GNAT.Dynamic_Tables;
28
29 with Namet; use Namet;
30 with Types; use Types;
31
32 package Prep is
33
34    -----------------
35    -- Symbol Data --
36    -----------------
37
38    type Symbol_Data is record
39       Symbol : Name_Id := No_Name;
40       --  The symbol in lower case
41
42       Original : Name_Id := No_Name;
43       --  The symbol as originally given in the definition file or on
44       --  the command line.
45
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
49       --  file symbols.
50
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.
54
55       Value : String_Id := No_String;
56       --  The value of the symbol (string or sequence of characters)
57
58    end record;
59
60    True_Value : Symbol_Data :=
61      (Symbol              => No_Name,
62       Original            => No_Name,
63       On_The_Command_Line => False,
64       Is_A_String         => False,
65       Value               => No_String);
66
67    type Symbol_Id is new Nat;
68    No_Symbol : constant Symbol_Id := 0;
69
70    package Symbol_Table is new GNAT.Dynamic_Tables
71      (Table_Component_Type => Symbol_Data,
72       Table_Index_Type     => Symbol_Id,
73       Table_Low_Bound      => 1,
74       Table_Initial        => 10,
75       Table_Increment      => 100);
76    --  The table of all symbols
77
78    Mapping : Symbol_Table.Instance;
79    --  The mapping table of symbols to values used by procedure Parse_Def_File
80    --  and Preprocess.
81
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.
85
86    --  Access to procedure types used by procedure Initialize below:
87
88    type Error_Msg_Proc is access procedure
89      (Msg : String; Flag_Location : Source_Ptr);
90
91    type Scan_Proc is access procedure;
92
93    type Set_Ignore_Errors_Proc is access procedure (To : Boolean);
94
95    type Put_Char_Proc is access procedure (C : Character);
96
97    type New_EOL_Proc is access procedure;
98
99    procedure Initialize
100      (Error_Msg         : Error_Msg_Proc;
101       Scan              : Scan_Proc;
102       Set_Ignore_Errors : Set_Ignore_Errors_Proc;
103       Put_Char          : Put_Char_Proc;
104       New_EOL           : New_EOL_Proc);
105
106    procedure Parse_Def_File;
107    --  Parse the definition file. The definition file must have already been
108    --  loaded and the scanner initialized.
109
110    procedure Preprocess;
111    --  Preprocess the input file. The input file must have already been loaded
112    --  and the scanner initialized.
113
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.
120
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.
126
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.
130
131 end Prep;