1
------------------------------------------------------------------------------
3
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
5
-- A 4 G . Q U E R I E S --
9
-- Copyright (c) 1995-2000, Free Software Foundation, Inc. --
11
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
12
-- under terms of the GNU General Public License as published by the Free --
13
-- Software Foundation; either version 2, or (at your option) any later --
14
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
15
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
16
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
17
-- Public License for more details. You should have received a copy of the --
18
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
19
-- COPYING. If not, write to the Free Software Foundation, 59 Temple Place --
20
-- - Suite 330, Boston, MA 02111-1307, USA. --
22
-- As a special exception, if other files instantiate generics from this --
23
-- unit, or you link this unit with other files to produce an executable, --
24
-- this unit does not by itself cause the resulting executable to be --
25
-- covered by the GNU General Public License. This exception does not --
26
-- however invalidate any other reasons why the executable file might be --
27
-- covered by the GNU Public License. --
29
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
30
-- Software Engineering Laboratory of the Swiss Federal Institute of --
31
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
32
-- Scientific Research Computer Center of Moscow State University (SRCC --
33
-- MSU), Russia, with funding partially provided by grants from the Swiss --
34
-- National Science Foundation and the Swiss Academy of Engineering --
35
-- Sciences. ASIS-for-GNAT is now maintained by Ada Core Technologies Inc --
36
-- (http://www.gnat.com). --
38
-- The original version of this component has been developed by Jean-Charles--
39
-- Marteau (Jean-Charles.Marteau@ensimag.imag.fr) and Serge Reboul --
40
-- (Serge.Reboul@ensimag.imag.fr), ENSIMAG High School Graduates (Computer --
41
-- sciences) Grenoble, France in Sema Group Grenoble, France. Now this --
42
-- component is maintained by the ASIS team --
44
------------------------------------------------------------------------------
46
--------------------------------------------------
47
-- The structure of this package is very basic, --
48
-- it consists in massive imbricated cases --
49
-- determining what element we're considering --
50
-- and returning an array containing its --
51
-- corresponding queries. --
52
--------------------------------------------------
56
with Asis.Declarations;
57
with Asis.Definitions;
59
with Asis.Expressions;
62
with A4G.Vcheck; use A4G.Vcheck;
64
package body A4G.Queries is
66
-----------------------
67
-- Local subprograms --
68
-----------------------
70
-- Subprograms declared below implement first-depth-level parsing of
71
-- Elements of specific kinds - they return a list of queries needed to
72
-- get all the first-depth-level components of teir argument in
73
-- from-left-to-right order
75
function PARSE_Defining_Name
76
(Ada_Defining_Name : in Asis.Element)
79
function PARSE_Association
80
(Ada_Association : in Asis.Element)
84
(Ada_Clause : in Asis.Element)
87
function PARSE_Expression
88
(Ada_Expression : in Asis.Element)
91
function PARSE_Path (Ada_Path : in Asis.Element) return Query_Array;
93
function PARSE_Definition
94
(Ada_Definition : in Asis.Element)
97
function PARSE_Declaration
98
(Ada_Declaration : in Asis.Element)
101
function PARSE_Statement
102
(Ada_Statement : in Asis.Element)
107
function PARSE_Defining_Name
108
(Ada_Defining_Name : in Asis.Element)
112
-- PARSE_Defining_Name deals with every Defining_Name 's Element_Kinds.
113
-- That is to say, it deals with Defining_Name_Kinds :
114
-- Not_A_Defining_Name, -- An unexpected element
115
-- A_Defining_Identifier, -- 3.1
116
-- A_Defining_Character_Literal, -- 3.5.1
117
-- A_Defining_Enumeration_Literal, -- 3.5.1
118
-- A_Defining_Operator_Symbol, -- 6.1
119
-- A_Defining_Expanded_Name.
120
-- 6.1 program_unit_name.defining_identifier
121
case Asis.Elements.Defining_Name_Kind (Ada_Defining_Name) is
123
-- Terminal Elements : DO NOTHING !!!!
124
when A_Defining_Identifier |
125
A_Defining_Character_Literal |
126
A_Defining_Enumeration_Literal |
127
A_Defining_Operator_Symbol =>
128
-- Terminal Elements : DO NOTHING !!!!
131
when A_Defining_Expanded_Name =>
133
(1 => (Single_Element_Query,
134
Asis.Declarations.Defining_Prefix'Access),
136
2 => (Single_Element_Query,
137
Asis.Declarations.Defining_Selector'Access));
139
when Not_A_Defining_Name =>
140
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Defining_Name");
142
end PARSE_Defining_Name;
144
function PARSE_Association
145
(Ada_Association : in Asis.Element)
149
case Asis.Elements.Association_Kind (Ada_Association) is
150
when Not_An_Association =>
151
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Association");
153
when A_Discriminant_Association =>
155
(1 => (Element_List_Query,
156
Asis.Expressions.Discriminant_Selector_Names'Access),
158
2 => (Single_Element_Query,
159
Asis.Expressions.Discriminant_Expression'Access));
161
when A_Record_Component_Association =>
163
(1 => (Element_List_Query,
164
Asis.Expressions.Record_Component_Choices'Access),
166
2 => (Single_Element_Query,
167
Asis.Expressions.Component_Expression'Access));
169
when An_Array_Component_Association =>
171
(1 => (Element_List_Query,
172
Asis.Expressions.Array_Component_Choices'Access),
174
2 => (Single_Element_Query,
175
Asis.Expressions.Component_Expression'Access));
177
when A_Parameter_Association |
178
A_Pragma_Argument_Association |
179
A_Generic_Association =>
181
(1 => (Single_Element_Query,
182
Asis.Expressions.Formal_Parameter'Access),
184
2 => (Single_Element_Query,
185
Asis.Expressions.Actual_Parameter'Access));
188
end PARSE_Association;
191
function PARSE_Clause
192
(Ada_Clause : in Asis.Element)
196
case Asis.Elements.Clause_Kind (Ada_Clause) is
198
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Clause");
200
when A_Use_Package_Clause |
204
(1 => (Element_List_Query, Asis.Clauses.Clause_Names'Access));
206
when A_Representation_Clause =>
207
case Asis.Elements.Representation_Clause_Kind (Ada_Clause) is
208
when Not_A_Representation_Clause =>
209
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Clause");
211
when An_Attribute_Definition_Clause |
212
An_Enumeration_Representation_Clause |
215
(1 => (Single_Element_Query,
216
Asis.Clauses.Representation_Clause_Name'Access),
218
2 => (Single_Element_Query,
219
Asis.Clauses.Representation_Clause_Expression'Access));
221
when A_Record_Representation_Clause =>
223
(1 => (Single_Element_Query,
224
Asis.Clauses.Representation_Clause_Name'Access),
226
2 => (Single_Element_Query,
227
Asis.Clauses.Mod_Clause_Expression'Access),
229
3 => (Element_List_Query_With_Boolean,
230
Asis.Clauses.Component_Clauses'Access, True));
234
when A_Component_Clause =>
236
(1 => (Single_Element_Query,
237
Asis.Clauses.Representation_Clause_Name'Access),
239
2 => (Single_Element_Query,
240
Asis.Clauses.Component_Clause_Position'Access),
242
3 => (Single_Element_Query,
243
Asis.Clauses.Component_Clause_Range'Access));
248
----------------------------------------------------------------------------
249
-- procedure PARSE_Expression
251
-- This procedure parse every expressions
252
-- The Expression_Kind are :
254
-- An_Integer_Literal, -- 2.4
255
-- A_Real_Literal, -- 2.4.1
256
-- A_String_Literal, -- 2.6
258
-- An_Identifier, -- 4.1
259
-- An_Operator_Symbol, -- 4.1
260
-- A_Character_Literal, -- 4.1
261
-- An_Enumeration_Literal, -- 4.1
262
-- An_Explicit_Dereference, -- 4.1
263
-- A_Function_Call, -- 4.1
265
-- An_Indexed_Component, -- 4.1.1
267
-- A_Selected_Component, -- 4.1.3
268
-- An_Attribute_Reference, -- 4.1.4
270
-- A_Record_Aggregate, -- 4.3
271
-- An_Extension_Aggregate, -- 4.3
272
-- A_Positional_Array_Aggregate, -- 4.3
273
-- A_Named_Array_Aggregate, -- 4.3
275
-- An_And_Then_Short_Circuit, -- 4.4
276
-- An_Or_Else_Short_Circuit, -- 4.4
278
-- An_In_Range_Membership_Test, -- 4.4
279
-- A_Not_In_Range_Membership_Test, -- 4.4
280
-- An_In_Type_Membership_Test, -- 4.4
281
-- A_Not_In_Type_Membership_Test, -- 4.4
283
-- A_Null_Literal, -- 4.4
284
-- A_Parenthesized_Expression, -- 4.4
286
-- A_Type_Conversion, -- 4.6
287
-- A_Qualified_Expression, -- 4.7
289
-- An_Allocation_From_Subtype, -- 4.8
290
-- An_Allocation_From_Qualified_Expression, -- 4.8
292
-- Not_An_Expression. -- An unexpected element
294
function PARSE_Expression
295
(Ada_Expression : in Asis.Element)
299
-- maybe there could be a factorization of all Prefix processing here
300
case Asis.Elements.Expression_Kind (Ada_Expression) is
301
when Not_An_Expression =>
302
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Expression");
304
when An_Integer_Literal |
309
A_Character_Literal |
310
An_Enumeration_Literal |
314
when An_Explicit_Dereference =>
317
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access));
319
when A_Function_Call =>
320
-- Abc(...) or Integer'Image(...)
322
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
323
2 => (Element_List_Query_With_Boolean,
324
Asis.Expressions.Function_Call_Parameters'Access, False));
326
when An_Indexed_Component =>
329
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
330
2 => (Element_List_Query,
331
Asis.Expressions.Index_Expressions'Access));
333
when A_Slice => -- An_Array(3 .. 5)
335
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
336
2 => (Single_Element_Query, Asis.Expressions.Slice_Range'Access));
338
when A_Selected_Component => -- A.B.C
340
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
341
2 => (Single_Element_Query, Asis.Expressions.Selector'Access));
343
when An_Attribute_Reference => -- Priv'Base'First
345
-- Attribute_Designator_Expressions
346
case Asis.Elements.Attribute_Kind (Ada_Expression) is
347
when Not_An_Attribute =>
348
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Expression");
350
when A_First_Attribute |
354
An_Implementation_Defined_Attribute |
355
An_Unknown_Attribute =>
358
(1 => (Single_Element_Query,
359
Asis.Expressions.Prefix'Access),
361
2 => (Single_Element_Query,
362
Asis.Expressions.Attribute_Designator_Identifier'Access),
363
3 => (Element_List_Query,
364
Asis.Expressions.Attribute_Designator_Expressions'Access));
368
(1 => (Single_Element_Query,
369
Asis.Expressions.Prefix'Access),
370
2 => (Single_Element_Query,
371
Asis.Expressions.Attribute_Designator_Identifier'Access));
374
when A_Record_Aggregate =>
375
-- (Field1 => value1, Field2 => value2)
378
(1 => (Element_List_Query_With_Boolean,
379
Asis.Expressions.Record_Component_Associations'Access, False));
381
when An_Extension_Aggregate =>
382
-- (Ewpr with Field1 => value1, Field2 => value2)
385
(1 => (Single_Element_Query,
386
Asis.Expressions.Extension_Aggregate_Expression'Access),
388
2 => (Element_List_Query_With_Boolean,
389
Asis.Expressions.Record_Component_Associations'Access, False));
392
when A_Positional_Array_Aggregate |
393
A_Named_Array_Aggregate =>
396
(1 => (Element_List_Query,
397
Asis.Expressions.Array_Component_Associations'Access));
399
when An_And_Then_Short_Circuit |
400
An_Or_Else_Short_Circuit =>
403
(1 => (Single_Element_Query,
404
Asis.Expressions.Short_Circuit_Operation_Left_Expression'Access),
406
2 => (Single_Element_Query,
407
Asis.Expressions.Short_Circuit_Operation_Right_Expression'Access));
409
when An_In_Range_Membership_Test |
410
A_Not_In_Range_Membership_Test =>
413
(1 => (Single_Element_Query,
414
Asis.Expressions.Membership_Test_Expression'Access),
416
2 => (Single_Element_Query,
417
Asis.Expressions.Membership_Test_Range'Access));
419
when An_In_Type_Membership_Test |
420
A_Not_In_Type_Membership_Test =>
423
(1 => (Single_Element_Query,
424
Asis.Expressions.Membership_Test_Expression'Access),
426
2 => (Single_Element_Query,
427
Asis.Expressions.Membership_Test_Subtype_Mark'Access));
429
when A_Parenthesized_Expression =>
432
(1 => (Single_Element_Query,
433
Asis.Expressions.Expression_Parenthesized'Access));
435
when A_Type_Conversion |
436
A_Qualified_Expression =>
439
(1 => (Single_Element_Query,
440
Asis.Expressions.Converted_Or_Qualified_Subtype_Mark'Access),
441
2 => (Single_Element_Query,
442
Asis.Expressions.Converted_Or_Qualified_Expression'Access));
444
when An_Allocation_From_Subtype =>
447
(1 => (Single_Element_Query,
448
Asis.Expressions.Allocator_Subtype_Indication'Access));
450
when An_Allocation_From_Qualified_Expression =>
453
(1 => (Single_Element_Query,
454
Asis.Expressions.Allocator_Qualified_Expression'Access));
457
end PARSE_Expression;
460
-----------------------------------------------------------------------
461
-- PARSE_Path deals with every Path 's Element_Kind.
462
-- That is to say, it deals with Path_Kinds :
463
-- Not_A_Path, -- An unexpected element
464
-- An_If_Path, -- 5.3:
465
-- -- if condition then
466
-- -- sequence_of_statements
467
-- An_Elsif_Path, -- 5.3:
468
-- -- elsif condition then
469
-- -- sequence_of_statements
470
-- An_Else_Path, -- 5.3, 9.7.1, 9.7.3:
471
-- -- else sequence_of_statements
472
-- A_Case_Path, -- 5.4:
473
-- -- when discrete_choice_list =>
474
-- -- sequence_of_statements
475
-- A_Select_Path, -- 9.7.1:
476
-- -- select [guard] select_alternative
478
-- -- select entry_call_alternative
480
-- -- select triggering_alternative
481
-- An_Or_Path, -- 9.7.1:
482
-- -- or [guard] select_alternative
484
-- -- or delay_alternative
485
-- A_Then_Abort_Path. -- 9.7.4
486
-- -- then abort sequence_of_statements
488
-- (See asis_element_kind.ads for more details)
490
function PARSE_Path (Ada_Path : in Asis.Element) return Query_Array is
492
case Asis.Elements.Path_Kind (Ada_Path) is
497
(1 => (Single_Element_Query,
498
Asis.Statements.Condition_Expression'Access),
500
2 => (Element_List_Query_With_Boolean,
501
Asis.Statements.Sequence_Of_Statements'Access, True));
507
(1 => (Element_List_Query_With_Boolean,
508
Asis.Statements.Sequence_Of_Statements'Access, True));
513
(1 => (Element_List_Query,
514
Asis.Statements.Case_Statement_Alternative_Choices'Access),
516
2 => (Element_List_Query_With_Boolean,
517
Asis.Statements.Sequence_Of_Statements'Access, True));
523
(1 => (Single_Element_Query, Asis.Statements.Guard'Access),
524
2 => (Element_List_Query_With_Boolean,
525
Asis.Statements.Sequence_Of_Statements'Access, True));
528
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Path");
534
-----------------------------------------------------------------------
535
-- procedure PARSE_Definition
537
-- This procedure parse every definitions
538
-- The Definition_Kinds are :
540
-- Definition_Kinds LRM P.
542
-----------------------------------------------------------------------
543
-- Not_A_Definition, -- An unexpected element
545
-- A_Type_Definition, -- 3.2.1
546
-- Not_A_Type_Definition, -- An unexpected element
547
-- A_Derived_Type_Definition, -- 3.4
548
-- A_Derived_Record_Extension_Definition, -- 3.4
549
-- An_Enumeration_Type_Definition, -- 3.5.1
550
-- A_Signed_Integer_Type_Definition, -- 3.5.4
551
-- A_Modular_Type_Definition, -- 3.5.4
552
-- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
553
-- A_Floating_Point_Definition, -- 3.5.7
554
-- An_Ordinary_Fixed_Point_Definition, -- 3.5.9
555
-- A_Decimal_Fixed_Point_Definition, -- 3.5.9
556
-- An_Unconstrained_Array_Definition, -- 3.6
557
-- A_Constrained_Array_Definition, -- 3.6
558
-- A_Record_Type_Definition, -- 3.8
559
-- A_Tagged_Record_Type_Definition, -- 3.8
560
-- An_Access_Type_Definition. -- 3.10
561
-- Not_An_Access_Type_Definition, -- An unexpected element
562
-- A_Pool_Specific_Access_To_Variable, -- access subtype_indication
563
-- An_Access_To_Variable, -- access all subtype_indication
564
-- An_Access_To_Constant, -- access constant subtype_indication
565
-- An_Access_To_Procedure, -- access procedure
566
-- An_Access_To_Protected_Procedure, -- access protected procedure
567
-- An_Access_To_Function, -- access function
568
-- An_Access_To_Protected_Function. -- access protected function
570
-- A_Subtype_Indication, -- 3.2.2
572
-- A_Constraint, -- 3.2.2
573
-- Not_A_Constraint, -- An unexpected element
574
-- A_Range_Attribute_Reference, -- 3.2.2, 3.5
575
-- A_Simple_Expression_Range, -- 3.2.2, 3.5
576
-- A_Digits_Constraint, -- 3.2.2, 3.5.9
577
-- A_Delta_Constraint, -- 3.2.2, J.3
578
-- An_Index_Constraint, -- 3.2.2, 3.6.1
579
-- A_Discriminant_Constraint. -- 3.2.2
581
-- A_Component_Definition, -- 3.6
583
-- A_Discrete_Subtype_Definition, -- 3.6
584
-- A_Discrete_Range, -- 3.6.1
585
-- Not_A_Discrete_Range, -- An unexpected element
586
-- A_Discrete_Subtype_Indication, -- 3.6.1, 3.2.2
587
-- A_Discrete_Range_Attribute_Reference, -- 3.6.1, 3.5
588
-- A_Discrete_Simple_Expression_Range. -- 3.6.1, 3.5
591
-- An_Unknown_Discriminant_Part, -- 3.7
592
-- A_Known_Discriminant_Part, -- 3.7
594
-- A_Record_Definition, -- 3.8
595
-- A_Null_Record_Definition, -- 3.8
597
-- A_Null_Component, -- 3.8
598
-- A_Variant_Part, -- 3.8
601
-- An_Others_Choice, -- 3.8.1, 4.3.1, 4.3.3, 11.2
603
-- A_Private_Type_Definition, -- 7.3
604
-- A_Tagged_Private_Type_Definition, -- 7.3
605
-- A_Private_Extension_Definition, -- 7.3
607
-- A_Task_Definition, -- 9.1
608
-- A_Protected_Definition, -- 9.4
610
-- A_Formal_Type_Definition. -- 12.5
611
-- Not_A_Formal_Type_Definition, -- An unexpected element
612
-- A_Formal_Private_Type_Definition, -- 12.5.1
613
-- A_Formal_Tagged_Private_Type_Definition, -- 12.5.1
614
-- A_Formal_Derived_Type_Definition, -- 12.5.1
615
-- A_Formal_Discrete_Type_Definition, -- 12.5.2
616
-- A_Formal_Signed_Integer_Type_Definition, -- 12.5.2
617
-- A_Formal_Modular_Type_Definition, -- 12.5.2
618
-- A_Formal_Floating_Point_Definition, -- 12.5.2
619
-- A_Formal_Ordinary_Fixed_Point_Definition, -- 12.5.2
620
-- A_Formal_Decimal_Fixed_Point_Definition, -- 12.5.2
621
-- A_Formal_Unconstrained_Array_Definition, -- 12.5.3
622
-- A_Formal_Constrained_Array_Definition, -- 12.5.3
623
-- A_Formal_Access_Type_Definition. -- 12.5.4
625
-----------------------------------------------------------------------
627
function PARSE_Definition
628
(Ada_Definition : in Asis.Element)
632
case Asis.Elements.Definition_Kind (Ada_Definition) is
633
when Not_A_Definition =>
634
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Definition");
636
-- A_Type_Definition. -- 3.2.1
637
when A_Type_Definition =>
638
case Asis.Elements.Type_Kind (Ada_Definition) is
639
-- Not_A_Type_Definition, -- An unexpected element
640
when Not_A_Type_Definition =>
641
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Definition");
643
-- A_Derived_Type_Definition, -- 3.4
644
when A_Derived_Type_Definition =>
647
(1 => (Single_Element_Query,
648
Asis.Definitions.Parent_Subtype_Indication'Access));
650
-- A_Derived_Record_Extension_Definition, -- 3.4
651
when A_Derived_Record_Extension_Definition =>
654
(1 => (Single_Element_Query,
655
Asis.Definitions.Parent_Subtype_Indication'Access),
657
2 => (Single_Element_Query,
658
Asis.Definitions.Record_Definition'Access));
660
-- An_Enumeration_Type_Definition, -- 3.5.1
661
when An_Enumeration_Type_Definition =>
664
(1 => (Element_List_Query,
665
Asis.Definitions.Enumeration_Literal_Declarations'Access));
667
-- A_Signed_Integer_Type_Definition, -- 3.5.4
668
when A_Signed_Integer_Type_Definition =>
671
(1 => (Single_Element_Query,
672
Asis.Definitions.Integer_Constraint'Access));
674
-- A_Modular_Type_Definition, -- 3.5.4
675
when A_Modular_Type_Definition =>
678
(1 => (Single_Element_Query,
679
Asis.Definitions.Mod_Static_Expression'Access));
681
-- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
682
when A_Root_Type_Definition =>
685
-- A_Floating_Point_Definition, -- 3.5.7
686
when A_Floating_Point_Definition =>
689
(1 => (Single_Element_Query,
690
Asis.Definitions.Digits_Expression'Access),
692
2 => (Single_Element_Query,
693
Asis.Definitions.Real_Range_Constraint'Access));
695
-- An_Ordinary_Fixed_Point_Definition, -- 3.5.9
696
when An_Ordinary_Fixed_Point_Definition =>
699
(1 => (Single_Element_Query,
700
Asis.Definitions.Delta_Expression'Access),
702
2 => (Single_Element_Query,
703
Asis.Definitions.Real_Range_Constraint'Access));
705
-- A_Decimal_Fixed_Point_Definition, -- 3.5.9
706
when A_Decimal_Fixed_Point_Definition =>
709
(1 => (Single_Element_Query,
710
Asis.Definitions.Delta_Expression'Access),
712
2 => (Single_Element_Query,
713
Asis.Definitions.Digits_Expression'Access),
715
3 => (Single_Element_Query,
716
Asis.Definitions.Real_Range_Constraint'Access));
718
-- An_Unconstrained_Array_Definition, -- 3.6
719
when An_Unconstrained_Array_Definition =>
722
(1 => (Element_List_Query,
723
Asis.Definitions.Index_Subtype_Definitions'Access),
725
2 => (Single_Element_Query,
726
Asis.Definitions.Array_Component_Definition'Access));
728
-- A_Constrained_Array_Definition, -- 3.6
729
when A_Constrained_Array_Definition =>
732
(1 => (Element_List_Query,
733
Asis.Definitions.Discrete_Subtype_Definitions'Access),
735
2 => (Single_Element_Query,
736
Asis.Definitions.Array_Component_Definition'Access));
738
-- A_Record_Type_Definition, -- 3.8
739
-- A_Tagged_Record_Type_Definition, -- 3.8
740
when A_Record_Type_Definition |
741
A_Tagged_Record_Type_Definition =>
744
(1 => (Single_Element_Query,
745
Asis.Definitions.Record_Definition'Access));
747
-- An_Access_Type_Definition. -- 3.10
748
when An_Access_Type_Definition =>
750
case Asis.Elements.Access_Type_Kind (Ada_Definition) is
751
-- Not_An_Access_Type_Definition,
752
when Not_An_Access_Type_Definition =>
754
("Asis.Elements.Queries.PARSE_Definition");
756
-- A_Pool_Specific_Access_To_Variable,
757
-- An_Access_To_Variable,
758
-- An_Access_To_Constant,
759
when A_Pool_Specific_Access_To_Variable |
760
An_Access_To_Variable |
761
An_Access_To_Constant =>
764
(1 => (Single_Element_Query,
765
Asis.Definitions.Access_To_Object_Definition'Access));
767
-- An_Access_To_Procedure,
768
-- An_Access_To_Protected_Procedure,
769
when An_Access_To_Procedure |
770
An_Access_To_Protected_Procedure =>
773
(1 => (Element_List_Query,
774
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access));
776
-- An_Access_To_Function,
777
-- An_Access_To_Protected_Function
778
when An_Access_To_Function |
779
An_Access_To_Protected_Function =>
782
(1 => (Element_List_Query,
783
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access),
785
2 => (Single_Element_Query,
786
Asis.Definitions.Access_To_Function_Result_Profile'Access));
791
-- A_Subtype_Indication, -- 3.2.2
792
when A_Subtype_Indication =>
795
(1 => (Single_Element_Query,
796
Asis.Definitions.Subtype_Mark'Access),
798
2 => (Single_Element_Query,
799
Asis.Definitions.Subtype_Constraint'Access));
801
-- A_Constraint, -- 3.2.2
803
case Asis.Elements.Constraint_Kind (Ada_Definition) is
804
-- Not_A_Constraint, -- An unexpected element
805
when Not_A_Constraint =>
807
("Asis.Elements.Queries.PARSE_Definition");
809
-- A_Range_Attribute_Reference, -- 3.2.2, 3.5
810
when A_Range_Attribute_Reference =>
813
(1 => (Single_Element_Query,
814
Asis.Definitions.Range_Attribute'Access));
816
-- A_Simple_Expression_Range, -- 3.2.2, 3.5
817
when A_Simple_Expression_Range =>
820
(1 => (Single_Element_Query,
821
Asis.Definitions.Lower_Bound'Access),
823
2 => (Single_Element_Query,
824
Asis.Definitions.Upper_Bound'Access));
826
-- A_Digits_Constraint, -- 3.2.2, 3.5.9
827
when A_Digits_Constraint =>
830
(1 => (Single_Element_Query,
831
Asis.Definitions.Digits_Expression'Access),
833
2 => (Single_Element_Query,
834
Asis.Definitions.Real_Range_Constraint'Access));
836
-- A_Delta_Constraint, -- 3.2.2, J.3
837
when A_Delta_Constraint =>
840
(1 => (Single_Element_Query,
841
Asis.Definitions.Delta_Expression'Access),
843
2 => (Single_Element_Query,
844
Asis.Definitions.Real_Range_Constraint'Access));
846
-- An_Index_Constraint, -- 3.2.2, 3.6.1
847
when An_Index_Constraint =>
850
(1 => (Element_List_Query,
851
Asis.Definitions.Discrete_Ranges'Access));
853
-- A_Discriminant_Constraint. -- 3.2.2
854
when A_Discriminant_Constraint =>
857
(1 => (Element_List_Query_With_Boolean,
858
Asis.Definitions.Discriminant_Associations'Access, False));
861
-- A_Component_Definition, -- 3.6
862
when A_Component_Definition =>
865
(1 => (Single_Element_Query,
866
Asis.Definitions.Component_Subtype_Indication'Access));
868
-- A_Discrete_Subtype_Definition, -- 3.6
869
-- A_Discrete_Range, -- 3.6.1
870
when A_Discrete_Subtype_Definition |
872
case Asis.Elements.Discrete_Range_Kind (Ada_Definition) is
873
-- Not_A_Discrete_Range, -- An unexpected element
874
when Not_A_Discrete_Range =>
876
("Asis.Elements.Queries.PARSE_Definition");
878
-- A_Discrete_Subtype_Indication, -- 3.6.1, 3.2.2
879
when A_Discrete_Subtype_Indication =>
882
(1 => (Single_Element_Query,
883
Asis.Definitions.Subtype_Mark'Access),
885
2 => (Single_Element_Query,
886
Asis.Definitions.Subtype_Constraint'Access));
888
-- A_Discrete_Range_Attribute_Reference, -- 3.6.1, 3.5
889
when A_Discrete_Range_Attribute_Reference =>
892
(1 => (Single_Element_Query,
893
Asis.Definitions.Range_Attribute'Access));
895
-- A_Discrete_Simple_Expression_Range. -- 3.6.1, 3.5
896
when A_Discrete_Simple_Expression_Range =>
899
(1 => (Single_Element_Query,
900
Asis.Definitions.Lower_Bound'Access),
902
2 => (Single_Element_Query,
903
Asis.Definitions.Upper_Bound'Access));
907
-- An_Unknown_Discriminant_Part, -- 3.7
908
when An_Unknown_Discriminant_Part =>
913
-- A_Known_Discriminant_Part, -- 3.7
914
when A_Known_Discriminant_Part =>
917
(1 => (Element_List_Query,
918
Asis.Definitions.Discriminants'Access));
920
-- A_Record_Definition, -- 3.8
921
when A_Record_Definition =>
924
(1 => (Element_List_Query_With_Boolean,
925
Asis.Definitions.Record_Components'Access, True));
927
-- A_Null_Record_Definition, -- 3.8
928
-- A_Null_Component, -- 3.8
929
when A_Null_Record_Definition |
934
-- A_Variant_Part, -- 3.8
935
when A_Variant_Part =>
938
(1 => (Single_Element_Query,
939
Asis.Definitions.Discriminant_Direct_Name'Access),
941
2 => (Element_List_Query_With_Boolean,
942
Asis.Definitions.Variants'Access, True));
948
(1 => (Element_List_Query,
949
Asis.Definitions.Variant_Choices'Access),
951
2 => (Element_List_Query_With_Boolean,
952
Asis.Definitions.Record_Components'Access, True));
954
-- An_Others_Choice, -- 3.8.1, 4.3.1, 4.3.3, 11.2
955
when An_Others_Choice =>
959
-- A_Private_Type_Definition, -- 7.3
960
-- A_Tagged_Private_Type_Definition, -- 7.3
961
when A_Private_Type_Definition |
962
A_Tagged_Private_Type_Definition =>
966
-- A_Private_Extension_Definition, -- 7.3
967
when A_Private_Extension_Definition =>
970
(1 => (Single_Element_Query,
971
Asis.Definitions.Ancestor_Subtype_Indication'Access));
973
-- A_Task_Definition, -- 9.1
974
-- A_Protected_Definition, -- 9.4
975
when A_Task_Definition |
976
A_Protected_Definition =>
979
(1 => (Element_List_Query_With_Boolean,
980
Asis.Definitions.Visible_Part_Items'Access, True),
982
2 => (Element_List_Query_With_Boolean,
983
Asis.Definitions.Private_Part_Items'Access, True));
985
-- A_Formal_Type_Definition. -- 12.5
986
when A_Formal_Type_Definition =>
987
case Asis.Elements.Formal_Type_Kind (Ada_Definition) is
988
-- Not_A_Formal_Type_Definition, -- An unexpected element
989
when Not_A_Formal_Type_Definition =>
990
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Definition");
992
-- A_Formal_Private_Type_Definition, -- 12.5.1
993
-- A_Formal_Tagged_Private_Type_Definition, -- 12.5.1
994
-- A_Formal_Discrete_Type_Definition, -- 12.5.2
995
-- A_Formal_Signed_Integer_Type_Definition, -- 12.5.2
996
-- A_Formal_Modular_Type_Definition, -- 12.5.2
997
-- A_Formal_Floating_Point_Definition, -- 12.5.2
998
-- A_Formal_Ordinary_Fixed_Point_Definition, -- 12.5.2
999
-- A_Formal_Decimal_Fixed_Point_Definition, -- 12.5.2
1000
when A_Formal_Private_Type_Definition |
1001
A_Formal_Tagged_Private_Type_Definition |
1002
A_Formal_Discrete_Type_Definition |
1003
A_Formal_Signed_Integer_Type_Definition |
1004
A_Formal_Modular_Type_Definition |
1005
A_Formal_Floating_Point_Definition |
1006
A_Formal_Ordinary_Fixed_Point_Definition |
1007
A_Formal_Decimal_Fixed_Point_Definition =>
1011
-- A_Formal_Derived_Type_Definition, -- 12.5.1
1012
when A_Formal_Derived_Type_Definition =>
1014
(1 => (Single_Element_Query,
1015
Asis.Definitions.Subtype_Mark'Access));
1017
-- A_Formal_Unconstrained_Array_Definition, -- 12.5.3
1018
when A_Formal_Unconstrained_Array_Definition =>
1021
(1 => (Element_List_Query,
1022
Asis.Definitions.Index_Subtype_Definitions'Access),
1024
2 => (Single_Element_Query,
1025
Asis.Definitions.Array_Component_Definition'Access));
1027
-- A_Formal_Constrained_Array_Definition, -- 12.5.3
1028
when A_Formal_Constrained_Array_Definition =>
1031
(1 => (Element_List_Query,
1032
Asis.Definitions.Discrete_Subtype_Definitions'Access),
1034
2 => (Single_Element_Query,
1035
Asis.Definitions.Array_Component_Definition'Access));
1037
-- A_Formal_Access_Type_Definition. -- 12.5.4
1038
when A_Formal_Access_Type_Definition =>
1040
case Asis.Elements.Access_Type_Kind (Ada_Definition) is
1041
-- Not_An_Access_Type_Definition,
1042
when Not_An_Access_Type_Definition =>
1044
("Asis.Elements.Queries.PARSE_Definition");
1046
-- A_Pool_Specific_Access_To_Variable,
1047
-- An_Access_To_Variable,
1048
-- An_Access_To_Constant,
1049
when A_Pool_Specific_Access_To_Variable |
1050
An_Access_To_Variable |
1051
An_Access_To_Constant =>
1054
(1 => (Single_Element_Query,
1055
Asis.Definitions.Access_To_Object_Definition'Access));
1057
-- An_Access_To_Procedure,
1058
-- An_Access_To_Protected_Procedure,
1059
when An_Access_To_Procedure |
1060
An_Access_To_Protected_Procedure =>
1063
(1 => (Element_List_Query,
1064
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access));
1066
-- An_Access_To_Function,
1067
-- An_Access_To_Protected_Function
1068
when An_Access_To_Function |
1069
An_Access_To_Protected_Function =>
1072
(1 => (Element_List_Query,
1073
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access),
1075
2 => (Single_Element_Query,
1076
Asis.Definitions.Access_To_Function_Result_Profile'Access));
1080
end PARSE_Definition;
1082
----------------------------------------------------------------------------
1083
-- procedure PARSE_Declaration
1085
-- This procedure parse every declarations
1086
-- The Declaration_Kinds are :
1088
-- Declaration_Kind LRM P.
1089
----------------------------------------------------------
1091
-- An_Ordinary_Type_Declaration, -- 3.2.1
1092
-- A_Task_Type_Declaration, -- 3.2.1
1093
-- A_Protected_Type_Declaration, -- 3.2.1
1094
-- An_Incomplete_Type_Declaration, -- 3.2.1
1095
-- A_Private_Type_Declaration, -- 3.2.1
1096
-- A_Private_Extension_Declaration, -- 3.2.1
1098
-- A_Subtype_Declaration, -- 3.2.2
1100
-- A_Variable_Declaration, -- 3.3.1
1101
-- A_Constant_Declaration, -- 3.3.1
1102
-- A_Deferred_Constant_Declaration, -- 3.3.1
1103
-- A_Single_Task_Declaration, -- 3.3.1
1104
-- A_Single_Protected_Declaration, -- 3.3.1
1106
-- An_Integer_Number_Declaration, -- 3.3.2
1107
-- A_Real_Number_Declaration, -- 3.3.2
1109
-- An_Enumeration_Literal_Specification, -- 3.5.1
1111
-- A_Discriminant_Specification, -- 3.7
1113
-- A_Component_Declaration, -- 3.8
1115
-- A_Loop_Parameter_Specification, -- 5.5
1117
-- A_Procedure_Declaration, -- 6.1
1118
-- A_Function_Declaration, -- 6.1
1120
-- A_Parameter_Specification, -- 6.1
1122
-- A_Procedure_Body_Declaration, -- 6.3
1123
-- A_Function_Body_Declaration, -- 6.3
1125
-- A_Package_Declaration, -- 7.1
1126
-- A_Package_Body_Declaration, -- 7.2
1128
-- An_Object_Renaming_Declaration, -- 8.5.1
1129
-- An_Exception_Renaming_Declaration, -- 8.5.2
1130
-- A_Package_Renaming_Declaration, -- 8.5.3
1131
-- A_Procedure_Renaming_Declaration, -- 8.5.4
1132
-- A_Function_Renaming_Declaration, -- 8.5.4
1133
-- A_Generic_Package_Renaming_Declaration, -- 8.5.5
1134
-- A_Generic_Procedure_Renaming_Declaration, -- 8.5.5
1135
-- A_Generic_Function_Renaming_Declaration, -- 8.5.5
1137
-- A_Task_Body_Declaration, -- 9.1
1138
-- A_Protected_Body_Declaration, -- 9.4
1140
-- An_Entry_Declaration, -- 9.5.2
1141
-- An_Entry_Body_Declaration, -- 9.5.2
1142
-- An_Entry_Index_Specification, -- 9.5.2
1144
-- A_Procedure_Body_Stub, -- 10.1.3
1145
-- A_Function_Body_Stub, -- 10.1.3
1146
-- A_Package_Body_Stub, -- 10.1.3
1147
-- A_Task_Body_Stub, -- 10.1.3
1148
-- A_Protected_Body_Stub, -- 10.1.3
1150
-- An_Exception_Declaration, -- 11.1
1151
-- A_Choice_Parameter_Specification, -- 11.2
1153
-- A_Generic_Procedure_Declaration, -- 12.1
1154
-- A_Generic_Function_Declaration, -- 12.1
1155
-- A_Generic_Package_Declaration, -- 12.1
1157
-- A_Package_Instantiation, -- 12.3
1158
-- A_Procedure_Instantiation, -- 12.3
1159
-- A_Function_Instantiation, -- 12.3
1161
-- A_Formal_Object_Declaration, -- 12.4
1162
-- A_Formal_Type_Declaration, -- 12.5
1163
-- A_Formal_Procedure_Declaration, -- 12.6
1164
-- A_Formal_Function_Declaration, -- 12.6
1165
-- A_Formal_Package_Declaration, -- 12.7
1166
-- A_Formal_Package_Declaration_With_Box, -- 12.7
1168
-- Not_A_Declaration. -- An unexpected element
1169
----------------------------------------------------------------------------
1171
function PARSE_Declaration
1172
(Ada_Declaration : in Asis.Element)
1176
case Asis.Elements.Declaration_Kind (Ada_Declaration) is
1178
-- An_Ordinary_Type_Declaration, -- 3.2.1
1179
-- A_Protected_Type_Declaration, -- 3.2.1
1180
-- A_Formal_Type_Declaration, -- 12.5
1181
when An_Ordinary_Type_Declaration |
1182
A_Protected_Type_Declaration |
1183
A_Formal_Type_Declaration =>
1186
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1188
2 => (Single_Element_Query,
1189
Asis.Declarations.Discriminant_Part'Access),
1190
3 => (Single_Element_Query,
1191
Asis.Declarations.Type_Declaration_View'Access));
1193
-- A_Task_Type_Declaration, -- 3.2.1
1194
-- A_Private_Type_Declaration, -- 3.2.1
1195
-- A_Private_Extension_Declaration, -- 3.2.1
1196
when A_Task_Type_Declaration |
1197
A_Private_Type_Declaration |
1198
A_Private_Extension_Declaration =>
1201
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1203
2 => (Single_Element_Query,
1204
Asis.Declarations.Discriminant_Part'Access),
1206
3 => (Single_Element_Query,
1207
Asis.Declarations.Type_Declaration_View'Access));
1209
-- An_Incomplete_Type_Declaration, -- 3.2.1
1210
when An_Incomplete_Type_Declaration =>
1213
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1215
2 => (Single_Element_Query,
1216
Asis.Declarations.Discriminant_Part'Access));
1218
-- A_Variable_Declaration, -- 3.3.1
1219
-- A_Constant_Declaration, -- 3.3.1
1220
when A_Variable_Declaration |
1221
A_Constant_Declaration =>
1224
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1226
2 => (Single_Element_Query,
1227
Asis.Declarations.Object_Declaration_View'Access),
1229
3 => (Single_Element_Query,
1230
Asis.Declarations.Initialization_Expression'Access));
1232
-- A_Deferred_Constant_Declaration, -- 3.3.1
1233
-- A_Single_Task_Declaration, -- 3.3.1
1234
-- A_Single_Protected_Declaration. -- 3.3.1
1235
when A_Deferred_Constant_Declaration |
1236
A_Single_Task_Declaration |
1237
A_Single_Protected_Declaration =>
1240
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1242
2 => (Single_Element_Query,
1243
Asis.Declarations.Object_Declaration_View'Access));
1245
-- An_Integer_Number_Declaration, -- 3.3.2
1246
-- A_Real_Number_Declaration, -- 3.3.2
1247
when An_Integer_Number_Declaration |
1248
A_Real_Number_Declaration =>
1251
(1 => (Element_List_Query,
1252
Asis.Declarations.Names'Access),
1254
2 => (Single_Element_Query,
1255
Asis.Declarations.Initialization_Expression'Access));
1257
-- A_Procedure_Declaration, -- 6.1
1258
-- A_Procedure_Body_Stub, -- 10.1.3
1259
when A_Procedure_Declaration |
1260
A_Procedure_Body_Stub =>
1262
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1264
2 => (Element_List_Query,
1265
Asis.Declarations.Parameter_Profile'Access));
1267
-- A_Function_Declaration, -- 6.1
1268
-- A_Function_Body_Stub, -- 10.1.3
1269
when A_Function_Declaration |
1270
A_Function_Body_Stub =>
1273
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1275
2 => (Element_List_Query,
1276
Asis.Declarations.Parameter_Profile'Access),
1278
3 => (Single_Element_Query,
1279
Asis.Declarations.Result_Profile'Access));
1281
-- A_Package_Declaration, -- 7.1
1282
when A_Package_Declaration =>
1285
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1287
2 => (Element_List_Query_With_Boolean,
1288
Asis.Declarations.Visible_Part_Declarative_Items'Access, True),
1290
3 => (Element_List_Query_With_Boolean,
1291
Asis.Declarations.Private_Part_Declarative_Items'Access, True));
1293
-- An_Entry_Declaration, -- 9.5.2
1294
when An_Entry_Declaration =>
1297
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1299
2 => (Single_Element_Query,
1300
Asis.Declarations.Entry_Family_Definition'Access),
1302
3 => (Element_List_Query,
1303
Asis.Declarations.Parameter_Profile'Access));
1305
-- A_Package_Body_Stub, -- 10.1.3
1306
-- A_Task_Body_Stub, -- 10.1.3
1307
-- A_Protected_Body_Stub, -- 10.1.3
1308
-- An_Exception_Declaration, -- 11.1
1309
when A_Package_Body_Stub |
1311
A_Protected_Body_Stub |
1312
An_Exception_Declaration =>
1315
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
1317
-- A_Generic_Procedure_Declaration, -- 12.1
1318
when A_Generic_Procedure_Declaration =>
1321
(1 => (Element_List_Query_With_Boolean,
1322
Asis.Declarations.Generic_Formal_Part'Access, True),
1324
2 => (Element_List_Query, Asis.Declarations.Names'Access),
1326
3 => (Element_List_Query,
1327
Asis.Declarations.Parameter_Profile'Access));
1330
-- A_Generic_Function_Declaration, -- 12.1
1331
when A_Generic_Function_Declaration =>
1334
(1 => (Element_List_Query_With_Boolean,
1335
Asis.Declarations.Generic_Formal_Part'Access, True),
1337
2 => (Element_List_Query,
1338
Asis.Declarations.Names'Access),
1340
3 => (Element_List_Query,
1341
Asis.Declarations.Parameter_Profile'Access),
1343
4 => (Single_Element_Query,
1344
Asis.Declarations.Result_Profile'Access));
1346
-- A_Generic_Package_Declaration. -- 12.1
1347
when A_Generic_Package_Declaration =>
1350
(1 => (Element_List_Query_With_Boolean,
1351
Asis.Declarations.Generic_Formal_Part'Access, True),
1353
2 => (Element_List_Query,
1354
Asis.Declarations.Names'Access),
1356
3 => (Element_List_Query_With_Boolean,
1357
Asis.Declarations.Visible_Part_Declarative_Items'Access,
1360
4 => (Element_List_Query_With_Boolean,
1361
Asis.Declarations.Private_Part_Declarative_Items'Access,
1364
-- A_Procedure_Body_Declaration, -- 6.3
1365
when A_Procedure_Body_Declaration =>
1368
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1370
2 => (Element_List_Query,
1371
Asis.Declarations.Parameter_Profile'Access),
1373
3 => (Element_List_Query_With_Boolean,
1374
Asis.Declarations.Body_Declarative_Items'Access,
1377
4 => (Element_List_Query_With_Boolean,
1378
Asis.Declarations.Body_Statements'Access,
1381
5 => (Element_List_Query_With_Boolean,
1382
Asis.Declarations.Body_Exception_Handlers'Access,
1385
-- A_Function_Body_Declaration, -- 6.3
1386
when A_Function_Body_Declaration =>
1389
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1391
2 => (Element_List_Query,
1392
Asis.Declarations.Parameter_Profile'Access),
1394
3 => (Single_Element_Query,
1395
Asis.Declarations.Result_Profile'Access),
1397
4 => (Element_List_Query_With_Boolean,
1398
Asis.Declarations.Body_Declarative_Items'Access,
1401
5 => (Element_List_Query_With_Boolean,
1402
Asis.Declarations.Body_Statements'Access,
1405
6 => (Element_List_Query_With_Boolean,
1406
Asis.Declarations.Body_Exception_Handlers'Access,
1409
-- A_Package_Body_Declaration, -- 7.2
1410
when A_Package_Body_Declaration =>
1413
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1415
2 => (Element_List_Query_With_Boolean,
1416
Asis.Declarations.Body_Declarative_Items'Access,
1419
3 => (Element_List_Query_With_Boolean,
1420
Asis.Declarations.Body_Statements'Access,
1423
4 => (Element_List_Query_With_Boolean,
1424
Asis.Declarations.Body_Exception_Handlers'Access,
1427
-- A_Task_Body_Declaration, -- 9.1
1428
when A_Task_Body_Declaration =>
1430
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1432
2 => (Element_List_Query_With_Boolean,
1433
Asis.Declarations.Body_Declarative_Items'Access,
1436
3 => (Element_List_Query_With_Boolean,
1437
Asis.Declarations.Body_Statements'Access, True),
1439
4 => (Element_List_Query_With_Boolean,
1440
Asis.Declarations.Body_Exception_Handlers'Access,
1443
-- An_Entry_Body_Declaration, -- 9.5.2
1444
when An_Entry_Body_Declaration =>
1447
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1449
2 => (Single_Element_Query,
1450
Asis.Declarations.Entry_Index_Specification'Access),
1452
3 => (Element_List_Query,
1453
Asis.Declarations.Parameter_Profile'Access),
1455
4 => (Single_Element_Query,
1456
Asis.Declarations.Entry_Barrier'Access),
1458
5 => (Element_List_Query_With_Boolean,
1459
Asis.Declarations.Body_Declarative_Items'Access,
1462
6 => (Element_List_Query_With_Boolean,
1463
Asis.Declarations.Body_Statements'Access,
1466
7 => (Element_List_Query_With_Boolean,
1467
Asis.Declarations.Body_Exception_Handlers'Access,
1470
-- A_Protected_Body_Declaration, -- 9.4
1471
when A_Protected_Body_Declaration =>
1474
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1475
2 => (Element_List_Query_With_Boolean,
1476
Asis.Declarations.Protected_Operation_Items'Access,
1479
-- An_Object_Renaming_Declaration, -- 8.5.1
1480
when An_Object_Renaming_Declaration =>
1483
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1485
2 => (Single_Element_Query,
1486
Asis.Declarations.Declaration_Subtype_Mark'Access),
1488
3 => (Single_Element_Query,
1489
Asis.Declarations.Renamed_Entity'Access));
1491
-- An_Exception_Renaming_Declaration, -- 8.5.2
1492
-- A_Package_Renaming_Declaration, -- 8.5.3
1493
-- A_Generic_Package_Renaming_Declaration, -- 8.5.5
1494
-- A_Generic_Procedure_Renaming_Declaration, -- 8.5.5
1495
-- A_Generic_Function_Renaming_Declaration. -- 8.5.5
1496
when An_Exception_Renaming_Declaration |
1497
A_Package_Renaming_Declaration |
1498
A_Generic_Package_Renaming_Declaration |
1499
A_Generic_Procedure_Renaming_Declaration |
1500
A_Generic_Function_Renaming_Declaration =>
1503
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1505
2 => (Single_Element_Query,
1506
Asis.Declarations.Renamed_Entity'Access));
1508
-- A_Procedure_Renaming_Declaration, -- 8.5.4
1509
when A_Procedure_Renaming_Declaration =>
1511
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1513
2 => (Element_List_Query,
1514
Asis.Declarations.Parameter_Profile'Access),
1516
3 => (Single_Element_Query,
1517
Asis.Declarations.Renamed_Entity'Access));
1519
-- A_Function_Renaming_Declaration, -- 8.5.4
1520
when A_Function_Renaming_Declaration =>
1522
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1524
2 => (Element_List_Query,
1525
Asis.Declarations.Parameter_Profile'Access),
1527
3 => (Single_Element_Query,
1528
Asis.Declarations.Result_Profile'Access),
1530
4 => (Single_Element_Query,
1531
Asis.Declarations.Renamed_Entity'Access));
1533
-- A_Package_Instantiation, -- 12.3
1534
-- A_Procedure_Instantiation, -- 12.3
1535
-- A_Function_Instantiation, -- 12.3
1536
-- A_Formal_Package_Declaration. -- 12.3
1537
when A_Package_Instantiation |
1538
A_Procedure_Instantiation |
1539
A_Function_Instantiation |
1540
A_Formal_Package_Declaration =>
1543
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1545
2 => (Single_Element_Query,
1546
Asis.Declarations.Generic_Unit_Name'Access),
1548
3 => (Element_List_Query_With_Boolean,
1549
Asis.Declarations.Generic_Actual_Part'Access,
1551
-- Will Parse the Actual_Part in the UN-Normalized Form.
1552
-- (as noticed in the Traverse_Element specification
1553
-- (see asisi_elements.ads))
1556
-- A_Subtype_Declaration, -- 3.2.2
1557
when A_Subtype_Declaration =>
1560
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1561
2 => (Single_Element_Query,
1562
Asis.Declarations.Type_Declaration_View'Access));
1564
-- An_Enumeration_Literal_Specification, -- 3.5.1
1565
when An_Enumeration_Literal_Specification =>
1568
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
1570
-- A_Discriminant_Specification, -- 3.7 -> Trait_Kinds
1571
-- A_Parameter_Specification, -- 6.1 -> Trait_Kinds
1572
when A_Discriminant_Specification |
1573
A_Parameter_Specification =>
1576
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1578
2 => (Single_Element_Query,
1579
Asis.Declarations.Declaration_Subtype_Mark'Access),
1581
3 => (Single_Element_Query,
1582
Asis.Declarations.Initialization_Expression'Access));
1584
-- A_Component_Declaration, -- 3.8
1585
when A_Component_Declaration =>
1588
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1590
2 => (Single_Element_Query,
1591
Asis.Declarations.Object_Declaration_View'Access),
1593
3 => (Single_Element_Query,
1594
Asis.Declarations.Initialization_Expression'Access));
1596
-- A_Loop_Parameter_Specification, -- 5.5 -> Trait_Kinds
1597
-- An_Entry_Index_Specification, -- 9.5.2
1598
when A_Loop_Parameter_Specification |
1599
An_Entry_Index_Specification =>
1602
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1604
2 => (Single_Element_Query,
1605
Asis.Declarations.Specification_Subtype_Definition'Access));
1607
-- A_Choice_Parameter_Specification, -- 11.2
1608
when A_Choice_Parameter_Specification =>
1611
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
1613
-- A_Formal_Object_Declaration, -- 12.4 -> Mode_Kinds
1614
when A_Formal_Object_Declaration =>
1616
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1618
2 => (Single_Element_Query,
1619
Asis.Declarations.Declaration_Subtype_Mark'Access),
1621
3 => (Single_Element_Query,
1622
Asis.Declarations.Initialization_Expression'Access));
1624
-- A_Formal_Procedure_Declaration, -- 12.6 -> Default_Kinds
1625
when A_Formal_Procedure_Declaration =>
1628
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1630
2 => (Element_List_Query,
1631
Asis.Declarations.Parameter_Profile'Access),
1633
3 => (Single_Element_Query,
1634
Asis.Extensions.Formal_Subprogram_Default'Access)
1635
-- Asis.Declarations.Formal_Subprogram_Default
1636
-- cannot be used here!
1639
-- A_Formal_Function_Declaration, -- 12.6 -> Default_Kinds
1640
when A_Formal_Function_Declaration =>
1643
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1645
2 => (Element_List_Query,
1646
Asis.Declarations.Parameter_Profile'Access),
1648
3 => (Single_Element_Query,
1649
Asis.Declarations.Result_Profile'Access),
1651
4 => (Single_Element_Query,
1652
Asis.Extensions.Formal_Subprogram_Default'Access)
1653
-- Asis.Declarations.Formal_Subprogram_Default
1654
-- cannot be used here!
1657
-- A_Formal_Package_Declaration_With_Box -- 12.7
1658
when A_Formal_Package_Declaration_With_Box =>
1661
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
1663
2 => (Single_Element_Query,
1664
Asis.Declarations.Generic_Unit_Name'Access));
1666
-- Not_A_Declaration, -- An unexpected element
1667
when Not_A_Declaration =>
1668
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Declaration");
1671
end PARSE_Declaration;
1673
function PARSE_Statement
1674
(Ada_Statement : in Asis.Element)
1678
-- all statements can have one or several Labels
1679
case Asis.Elements.Statement_Kind (Ada_Statement) is
1680
when Not_A_Statement =>
1681
Raise_ASIS_Failed ("Asis.Elements.Queries.PARSE_Statement");
1683
when A_Null_Statement =>
1686
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access));
1688
when An_Assignment_Statement =>
1691
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1693
2 => (Single_Element_Query,
1694
Asis.Statements.Assignment_Variable_Name'Access),
1696
3 => (Single_Element_Query,
1697
Asis.Statements.Assignment_Expression'Access));
1699
when An_If_Statement |
1700
A_Selective_Accept_Statement |
1701
A_Timed_Entry_Call_Statement |
1702
A_Conditional_Entry_Call_Statement |
1703
An_Asynchronous_Select_Statement =>
1706
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1707
2 => (Element_List_Query_With_Boolean,
1708
Asis.Statements.Statement_Paths'Access,
1711
when A_Case_Statement =>
1714
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1716
2 => (Single_Element_Query,
1717
Asis.Statements.Case_Expression'Access),
1719
3 => (Element_List_Query_With_Boolean,
1720
Asis.Statements.Statement_Paths'Access,
1723
when A_Loop_Statement =>
1726
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1728
2 => (Single_Element_Query,
1729
Asis.Statements.Statement_Identifier'Access),
1731
3 => (Element_List_Query_With_Boolean,
1732
Asis.Statements.Loop_Statements'Access,
1735
when A_While_Loop_Statement =>
1738
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1740
2 => (Single_Element_Query,
1741
Asis.Statements.Statement_Identifier'Access),
1743
3 => (Single_Element_Query,
1744
Asis.Statements.While_Condition'Access),
1746
4 => (Element_List_Query_With_Boolean,
1747
Asis.Statements.Loop_Statements'Access,
1750
when A_For_Loop_Statement =>
1753
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1755
2 => (Single_Element_Query,
1756
Asis.Statements.Statement_Identifier'Access),
1758
3 => (Single_Element_Query,
1759
Asis.Statements.For_Loop_Parameter_Specification'Access),
1761
4 => (Element_List_Query_With_Boolean,
1762
Asis.Statements.Loop_Statements'Access,
1765
when A_Block_Statement =>
1768
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1770
2 => (Single_Element_Query,
1771
Asis.Statements.Statement_Identifier'Access),
1773
3 => (Element_List_Query_With_Boolean,
1774
Asis.Statements.Block_Declarative_Items'Access,
1777
4 => (Element_List_Query_With_Boolean,
1778
Asis.Statements.Block_Statements'Access,
1781
5 => (Element_List_Query_With_Boolean,
1782
Asis.Statements.Block_Exception_Handlers'Access,
1785
when An_Exit_Statement =>
1788
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1790
2 => (Single_Element_Query,
1791
Asis.Statements.Exit_Loop_Name'Access),
1793
3 => (Single_Element_Query,
1794
Asis.Statements.Exit_Condition'Access));
1796
when A_Goto_Statement =>
1799
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1800
2 => (Single_Element_Query, Asis.Statements.Goto_Label'Access));
1802
when A_Procedure_Call_Statement |
1803
An_Entry_Call_Statement =>
1806
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1807
2 => (Single_Element_Query, Asis.Statements.Called_Name'Access),
1809
3 => (Element_List_Query_With_Boolean,
1810
Asis.Statements.Call_Statement_Parameters'Access,
1813
when A_Return_Statement =>
1816
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1818
2 => (Single_Element_Query,
1819
Asis.Statements.Return_Expression'Access));
1821
when An_Accept_Statement =>
1824
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1826
2 => (Single_Element_Query,
1827
Asis.Statements.Accept_Entry_Direct_Name'Access),
1829
3 => (Single_Element_Query,
1830
Asis.Statements.Accept_Entry_Index'Access),
1832
4 => (Element_List_Query,
1833
Asis.Statements.Accept_Parameters'Access),
1835
5 => (Element_List_Query_With_Boolean,
1836
Asis.Statements.Accept_Body_Statements'Access, True),
1838
6 => (Element_List_Query_With_Boolean,
1839
Asis.Statements.Accept_Body_Exception_Handlers'Access,
1842
when A_Requeue_Statement |
1843
A_Requeue_Statement_With_Abort =>
1846
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1848
2 => (Single_Element_Query,
1849
Asis.Statements.Requeue_Entry_Name'Access));
1851
when A_Delay_Until_Statement |
1852
A_Delay_Relative_Statement =>
1855
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1857
2 => (Single_Element_Query,
1858
Asis.Statements.Delay_Expression'Access));
1860
when A_Terminate_Alternative_Statement =>
1864
when An_Abort_Statement =>
1867
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1869
2 => (Element_List_Query,
1870
Asis.Statements.Aborted_Tasks'Access));
1872
when A_Raise_Statement =>
1875
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1877
2 => (Single_Element_Query,
1878
Asis.Statements.Raised_Exception'Access));
1880
when A_Code_Statement =>
1883
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
1885
2 => (Single_Element_Query,
1886
Asis.Statements.Qualified_Expression'Access));
1890
end PARSE_Statement;
1892
-- We've separated the functions to make the program clearer,
1893
-- but it is better to expand them inline ...
1894
pragma Inline (PARSE_Defining_Name);
1895
pragma Inline (PARSE_Declaration);
1896
pragma Inline (PARSE_Definition);
1897
pragma Inline (PARSE_Expression);
1898
pragma Inline (PARSE_Association);
1899
pragma Inline (PARSE_Statement);
1900
pragma Inline (PARSE_Path);
1901
pragma Inline (PARSE_Clause);
1903
function Appropriate_Queries (Element : Asis.Element) return Query_Array is
1905
case Asis.Elements.Element_Kind (Element) is
1906
when Not_An_Element =>
1912
(1 => (Element_List_Query,
1913
Asis.Elements.Pragma_Argument_Associations'Access));
1915
when A_Defining_Name =>
1917
return PARSE_Defining_Name (Element);
1919
when A_Declaration =>
1921
return PARSE_Declaration (Element);
1923
when A_Definition =>
1925
return PARSE_Definition (Element);
1927
when An_Expression =>
1929
return PARSE_Expression (Element);
1931
when An_Association =>
1933
return PARSE_Association (Element);
1937
return PARSE_Statement (Element);
1941
return PARSE_Path (Element);
1945
return PARSE_Clause (Element);
1947
when An_Exception_Handler =>
1950
(1 => (Single_Element_Query,
1951
Asis.Statements.Choice_Parameter_Specification'Access),
1953
2 => (Element_List_Query,
1954
Asis.Statements.Exception_Choices'Access),
1956
3 => (Element_List_Query_With_Boolean,
1957
Asis.Statements.Handler_Statements'Access, True));
1959
end Appropriate_Queries;
b'\\ No newline at end of file'