OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--    O C A R I N A . B A C K E N D S . A S N 1 _ T R E E . N U T I L S     --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--         Copyright (C) 2010-2019 ESA & ISAE, 2019-2020 OpenAADL           --
10
--                                                                          --
11
-- Ocarina  is free software; you can redistribute it and/or modify under   --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
15
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
16
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
--                    Ocarina is maintained by OpenAADL team                --
28
--                              (info@openaadl.org)                         --
29
--                                                                          --
30
------------------------------------------------------------------------------
31

32
with Ocarina.Backends.ASN1_Tree.Nodes;
33
with Ocarina.Backends.ASN1_Values;
34

35 1
package Ocarina.Backends.ASN1_Tree.Nutils is
36

37
   package ASN1_Nodes renames Ocarina.Backends.ASN1_Tree.Nodes;
38

39
   use Ocarina.Backends.ASN1_Values;
40

41
   type Token_Type is
42
     (
43
   --   Token name      Token type
44
   --   Keywords
45
   Tok_Null,            -- NULL   **** First Keyword
46
      Tok_Module,          -- MODULE
47

48
   --  Graphic Characters
49
      Tok_Xor,             -- ^
50
      Tok_Sharp,           -- #
51
      Tok_Mod,             -- %
52
      Tok_Not,             -- !
53
      Tok_Left_Brace,      -- {
54
      Tok_Right_Brace,     -- }
55
      Tok_Or,              -- ||
56
      Tok_And,             -- &&
57
      Tok_Ampersand,       -- &
58
      Tok_Minus,           -- -
59
      Tok_Underscore,      -- _
60
      Tok_Plus,            -- +
61
      Tok_Asterisk,        -- *
62
      Tok_Slash,           -- /
63
      Tok_Quote,           -- "
64
      Tok_Dot,             -- .
65
      Tok_Apostrophe,      -- '
66
      Tok_Left_Paren,      -- (
67
      Tok_Right_Paren,     -- )
68
      Tok_Left_Hook,       -- [
69
      Tok_Right_Hook,      -- ]
70
      Tok_Comma,           -- ,
71
      Tok_Less,            -- <
72
      Tok_Equal,           -- =
73
      Tok_Equal_Equal,     -- ==
74
      Tok_Greater,         -- >
75
      Tok_Not_Equal,       -- /=
76
      Tok_Greater_Equal,   -- >=
77
      Tok_Less_Equal,      -- <=
78
      Tok_Colon,           -- :
79
      Tok_Greater_Greater, -- >>
80
      Tok_Less_Less,       -- <<
81
      Tok_Semicolon,       -- ;
82
      Tok_Arrow,           -- ->
83
      Tok_Vertical_Bar);   -- |
84

85 1
   Token_Image : array (Token_Type) of Name_Id;
86

87
   subtype Keyword_Type is Token_Type range Tok_Null .. Tok_Module;
88

89
   type Operator_Type is
90
     (Op_Not,             -- not
91
      Op_And,             -- and
92
      Op_In,              -- in
93
      Op_And_Then,        -- and then
94
      Op_Or,              -- or
95
      Op_Or_Else,         -- or else
96
      Op_And_Symbol,      -- &
97
      Op_Double_Asterisk, -- **
98
      Op_Minus,           -- -
99
      Op_Plus,            -- +
100
      Op_Asterisk,        -- *
101
      Op_Slash,           -- /
102
      Op_Less,            -- <
103
      Op_Equal,           -- =
104
      Op_Equal_Equal,     -- ==
105
      Op_Greater,         -- >
106
      Op_Not_Equal,       -- !=
107
      Op_Greater_Equal,   -- >=
108
      Op_Less_Equal,      -- <=
109
      Op_Greater_Greater, -- >>
110
      Op_Less_Less,       -- <<
111
      Op_Semicolon,       -- ;
112
      Op_Arrow,           -- ->
113
      Op_Vertical_Bar,    -- |
114
      Op_None);           -- No operation
115

116 1
   Operator_Image : array
117
   (Operator_Type'Pos (Op_And) ..
118
        Operator_Type'Pos (Op_Vertical_Bar)) of Name_Id;
119

120
   subtype Keyword_Operator is
121
     Operator_Type range Operator_Type'First .. Op_Or_Else;
122

123
   function Length (L : List_Id) return Natural;
124

125
   function Is_Empty (L : List_Id) return Boolean;
126

127
   procedure Reset;
128

129
   procedure Initialize;
130

131
   function New_List
132
     (Kind : ASN1_Nodes.Node_Kind;
133
      From : Node_Id := No_Node) return List_Id;
134

135
   function Image (O : Operator_Type) return String;
136

137
   function Image (T : Token_Type) return String;
138

139
   function Copy_Node (N : Node_Id) return Node_Id;
140

141
   procedure Insert_Before_Node (E : Node_Id; N : Node_Id; L : List_Id);
142

143
   procedure Insert_After_Node (E : Node_Id; N : Node_Id);
144

145
   procedure Append_Node_To_List (E : Node_Id; L : List_Id);
146

147
   function Remove_Suffix_From_Name
148
     (Suffix : String;
149
      Name   : Name_Id) return Name_Id;
150

151
   function Add_Suffix_To_Name
152
     (Suffix : String;
153
      Name   : Name_Id) return Name_Id;
154

155
   function Add_Prefix_To_Name
156
     (Prefix : String;
157
      Name   : Name_Id) return Name_Id;
158

159
   function New_Node
160
     (Kind : ASN1_Nodes.Node_Kind;
161
      From : Node_Id := No_Node) return Node_Id;
162

163
   procedure New_Token (T : Token_Type; I : String := "");
164

165
   function Make_ASN1_File (Identifier : Node_Id) return Node_Id;
166
   --  Build a node that describes an ASN1 file. The name
167
   --  of the file is described in the parameter.
168

169
   function Make_Defining_Identifier (Name : Name_Id) return Node_Id;
170
   --  Build a node that contains an identifier.
171

172
   function Make_Enumerated_Value (Name : Name_Id) return Node_Id;
173
   --  Build a node that describes a member of an enumeration but
174
   --  does not associate any value with it.
175

176
   function Make_Enumerated_Value
177
     (Name : Name_Id;
178
      V    : Unsigned_Long_Long) return Node_Id;
179
   --  Make a node that describes a member of an enumeration and associated
180
   --  an integer value to it. The first parameter is the name of the
181
   --  enumeration while the second is its corresponding value.
182

183
   function Make_Enumerated return Node_Id;
184
   --  Make an enumeration definition list with an empty list of
185
   --  values.
186

187
   function Make_Enumerated (L : List_Id) return Node_Id;
188
   --  Make an enumerated nodes. The parameters are the values
189
   --  of the enumeration. The returned node_id can be associated
190
   --  with a type definition.
191

192
   function Make_Type_Definition
193
     (Name : Name_Id;
194
      Decl : Node_Id) return Node_Id;
195
   --  Make a Type_Definition node. First parameter is the name
196
   --  of the type, the second one is the declaration of this type
197
   --  Enumerated/Choice/... node.
198

199
   function Make_Literal (Value : Value_Id) return Node_Id;
200
   --  Make a Literal that contains a value (Value-Id), see
201
   --  Ocarina.Backends.ASN1_Values for more information.
202

203
   function Make_Sequence (Sequence_Members : List_Id) return Node_Id;
204
   --  Make a sequence that contains the members given in parameter.
205

206
   function Make_Sequence_Member
207
     (Member_Name : Name_Id;
208
      Member_Type : Node_Id) return Node_Id;
209
   --  Make a sequence member identified by Member_Name which has the
210
   --  type Member_Type.
211

212
   function Make_Choice (Choice_Members : List_Id) return Node_Id;
213
   --  Make a choice that contains the members given in parameter.
214

215
   function Make_Choice_Member
216
     (Member_Name : Name_Id;
217
      Member_Type : Node_Id) return Node_Id;
218
   --  Make a choice member identified by Member_Name which has the
219
   --  type Member_Type.
220

221
   function Make_Type_Designator
222
     (Type_Name        : Node_Id;
223
      Type_Constraints : Node_Id := No_Node) return Node_Id;
224
   --  Make a node that points to a type. The type name is either a reference
225
   --  to a type node, either a defining_identifier node that contains
226
   --  the name of the pointed type. The second parameter is optional
227
   --  and defines the constraints associated with the type designation.
228
   --  You can look at the Make_Type_Constraints function for more
229
   --  information.
230

231
   function Make_Type_Constraints
232
     (Size_Up   : Value_Id := No_Value;
233
      Size_Down : Value_Id := No_Value) return Node_Id;
234
   --  Make the Type_Constraints node. This node contains all potential
235
   --  constraints that a type designator can contain. So, all parameters
236
   --  are not mandatory and have a default value.
237

238 1
end Ocarina.Backends.ASN1_Tree.Nutils;

Read our documentation on viewing source code .

Loading