1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2005, 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 -- This package implements parsing of string expressions in project files
29 with Prj
.Tree
; use Prj
.Tree
;
31 private package Prj
.Strt
is
33 procedure Parse_String_Type_List
34 (In_Tree
: Project_Node_Tree_Ref
;
35 First_String
: out Project_Node_Id
);
36 -- Get the list of literal strings that are allowed for a typed string.
37 -- On entry, the current token is the first literal string following
38 -- a left parenthesis in a string type declaration such as:
39 -- type Toto is ("string_1", "string_2", "string_3");
40 -- On exit, the current token is the right parenthesis.
41 -- The parameter First_String is a node that contained the first
42 -- literal string of the string type, linked with the following
46 -- - a literal string is not found at the beginning of the list
48 -- - two literal strings in the list are equal
50 procedure Start_New_Case_Construction
51 (In_Tree
: Project_Node_Tree_Ref
;
52 String_Type
: Project_Node_Id
);
53 -- This procedure is called at the beginning of a case construction
54 -- The parameter String_Type is the node for the string type
55 -- of the case label variable.
56 -- The different literal strings of the string type are stored
57 -- into a table to be checked against the case labels of the
60 procedure End_Case_Construction
61 (Check_All_Labels
: Boolean;
62 Case_Location
: Source_Ptr
);
63 -- This procedure is called at the end of a case construction
64 -- to remove the case labels and to restore the previous state.
65 -- In particular, in the case of nested case constructions,
66 -- the case labels of the enclosing case construction are restored.
67 -- When When_Others is False and we are not in quiet output, a warning
68 -- is emitted for each value of the case variable string type that has
69 -- not been specified.
71 procedure Parse_Choice_List
72 (In_Tree
: Project_Node_Tree_Ref
;
73 First_Choice
: out Project_Node_Id
);
74 -- Get the label for a choice list.
76 -- - a case label is not a literal string
77 -- - a case label is not in the typed string list
78 -- - the same case label is repeated in the same case construction
80 procedure Parse_Expression
81 (In_Tree
: Project_Node_Tree_Ref
;
82 Expression
: out Project_Node_Id
;
83 Current_Project
: Project_Node_Id
;
84 Current_Package
: Project_Node_Id
;
85 Optional_Index
: Boolean);
86 -- Parse a simple string expression or a string list expression.
87 -- Current_Project is the node of the project file being parsed.
88 -- Current_Package is the node of the package being parsed,
89 -- or Empty_Node when we are at the project level (not in a package).
90 -- On exit, Expression is the node of the expression that has
93 procedure Parse_Variable_Reference
94 (In_Tree
: Project_Node_Tree_Ref
;
95 Variable
: out Project_Node_Id
;
96 Current_Project
: Project_Node_Id
;
97 Current_Package
: Project_Node_Id
);
98 -- Parse a variable or attribute reference.
99 -- Used internally (in expressions) and for case variables (in Prj.Dect).
100 -- Current_Package is the node of the package being parsed,
101 -- or Empty_Node when we are at the project level (not in a package).
102 -- On exit, Variable is the node of the variable or attribute reference.
103 -- A variable reference is made of one to three simple names.
104 -- An attribute reference is made of one or two simple names,
105 -- followed by an apostroph, followed by the attribute simple name.