ada.editor/src/org/netbeans/modules/ada/editor/parser/resources/Ada95ASTParser.cup
Add JVM compiler support.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
24 * If you wish your version of this file to be governed by only the CDDL
25 * or only the GPL Version 2, indicate your decision by adding
26 * "[Contributor] elects to include this software in this distribution
27 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28 * single choice of license, a recipient has the option to distribute
29 * your version of this file under either the CDDL, the GPL Version 2 or
30 * to extend the choice of license to its licensees as provided above.
31 * However, if you add GPL Version 2 code and therefore, elected the GPL
32 * Version 2 license, then the option applies only if the new code is
33 * made subject to such option by the copyright holder.
37 * Portions Copyrighted 2008 Sun Microsystems, Inc.
39 package org.netbeans.modules.ada.editor.parser;
42 import org.netbeans.modules.ada.editor.lexer.Ada95ASTLexer;
43 import org.netbeans.modules.ada.editor.ast.*;
44 import org.netbeans.modules.ada.editor.ast.nodes.*;
47 protected final static Integer PUBLIC = new Integer(BodyDeclaration.Modifier.PUBLIC);
48 protected final static Integer PRIVATE = new Integer(BodyDeclaration.Modifier.PRIVATE);
49 protected final static Integer TAGGED = new Integer(BodyDeclaration.Modifier.TAGGED);
50 protected final static Integer LIMITED = new Integer(BodyDeclaration.Modifier.LIMITED);
51 protected final static Integer ABSTRACT = new Integer(BodyDeclaration.Modifier.ABSTRACT);
53 private ErrorStrategy defaultStrategy = new DefaultErrorStrategy();;
54 private ErrorStrategy errorStrategy = defaultStrategy;
56 private ParserErrorHandler errorHandler = null;
58 public void setErrorHandler (ParserErrorHandler handler) {
59 this.errorHandler = handler;
62 public ParserErrorHandler getErrorHandler () {
63 return this.errorHandler;
67 public Dispatch createDispatch(NameBase dispatcher, NameBase property) {
68 Dispatch dispatch = null;
69 if (property instanceof Variable) {
70 dispatch = new FieldAccess(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (Variable)property);
71 } else if (property instanceof TypeName) {
72 dispatch = new TypeAccess(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (TypeName)property);
74 throw new IllegalArgumentException();
80 public List setModifier(List items, int modifier) {
81 List list = new LinkedList();
82 for (Iterator iter = items.iterator(); iter.hasNext();) {
83 final Object next = iter.next();
84 if (next instanceof TypeDeclaration) {
85 ((TypeDeclaration)next).setModifier(modifier);
87 } else if (next instanceof MethodDeclaration) {
88 ((MethodDeclaration)next).setModifier(modifier);
90 } else if (next instanceof FieldsDeclaration) {
91 ((FieldsDeclaration)next).setModifier(modifier);
100 interface ErrorStrategy {
101 public boolean errorRecovery(boolean debug) throws Exception;
104 class DefaultErrorStrategy implements ErrorStrategy {
106 public boolean errorRecovery(boolean debug) throws Exception {
107 return Ada95ASTParser.super.error_recovery(debug);
112 * Attempt to recover from a syntax error. This returns false if recovery fails,
113 * true if it succeeds.
114 * @param debug should we produce debugging messages as we parse.
117 protected boolean error_recovery(boolean debug) throws java.lang.Exception {
118 return errorStrategy.errorRecovery(debug);
122 * Report a non fatal error (or warning). This method takes a message
123 * string and an additional object (to be used by specializations implemented in subclasses).
124 * The super class prints the message to System.err.
125 * @param message an error message.
126 * @param info an extra object reserved for use by specialized subclasses.
129 public void report_error(String message, Object info) {
130 System.out.print("report_eror" + message);
134 * This method is called when a syntax error has been detected and recovery is about to be invoked.
135 * The super class just emit a "Syntax error" error message.
136 * @param cur_token the current lookahead Symbol.
139 public void syntax_error(java_cup.runtime.Symbol cur_token) {
140 java_cup.runtime.Symbol symbol = (java_cup.runtime.Symbol)stack.peek();
141 int state = symbol.parse_state;
142 short[] rowOfProbe = action_tab[state];
143 if (errorHandler != null) {
144 errorHandler.handleError(ParserErrorHandler.Type.SYNTAX_ERROR, rowOfProbe, cur_token, symbol);
149 * This method is called when a syntax error has been detected during action.
150 * @param message an error message.
152 public void message_error(String message) {
153 java_cup.runtime.Symbol symbol = (java_cup.runtime.Symbol)stack.peek();
154 if (errorHandler != null) {
155 errorHandler.handleError(ParserErrorHandler.Type.SYNTAX_ERROR, symbol, message);
160 * Report a fatal error. This method takes a message string and an additional object
161 * (to be used by specializations implemented in subclasses).
162 * The super class reports the error then throws an exception.
163 * @param message an error message.
164 * @param info an extra object reserved for use by specialized subclasses.
167 public void report_fatal_error(String message, Object info) throws Exception {
168 if (errorHandler != null) {
169 errorHandler.handleError(ParserErrorHandler.Type.FATAL_PARSER_ERROR, null, cur_token, null);
174 protected int error_sync_size() {
181 /*********************************************************
183 * Ada 95 (LALR) AST Parser, based on: *
185 * 1. Ada Reference Manual *
186 * ISO/IEC 8652:1995(E) *
187 * with Technical Corrigendum 1 *
188 * Language and Standard Libraries *
189 * Copyright © 1992,1993,1994,1995 Intermetrics, Inc. *
190 * Copyright © 2000 The MITRE Corporation, Inc. *
191 * 2. http://www.adaic.com/standards/95lrm/grammar9x.y *
193 * Author: Andrea Lucarelli *
194 * Parser Generator: JavCup *
196 *********************************************************/
198 /*************************
199 * JavaCup Terminals *
200 *************************/
275 // 2.2 Lexical Elements, Separators, and Delimiters
298 // compound delimiters
314 // ??? terminal String OPERATOR_SYMBOL;
315 terminal String CHAR_LITERAL; // 2.1 Character Set
316 terminal String IDENTIFIER; // 2.3 Identifiers
317 terminal String DECIMAL_LITERAL; // 2.4.1 Decimal Literals
318 terminal String BASED_LITERAL; // 2.4.2 Based Literals
319 terminal String STRING_LITERAL; // 2.6 String Literals
322 /*************************
323 * JavaCup Non terminals *
324 *************************/
327 non terminal Statement declaration;
328 non terminal List fields_declaration;
329 non terminal Statement type_declaration;
330 non terminal Statement subprog_declaration;
331 non terminal Identifier defining_identifier;
333 // 3.11 Declarative Parts
334 non terminal List declarative_items_opt;
335 non terminal List declarative_item_list;
336 non terminal Statement declarative_item;
337 non terminal List declarative_part;
338 non terminal List declarative_item_or_body_s1;
339 non terminal List private_part;
340 non terminal Statement proper_body;
341 non terminal Statement task_body;
343 // 3.2.1 Type Declarations
344 non terminal Expression type_definition;
346 // 3.2.2 Subtype Declarations
347 non terminal Statement subtype_declaration;
348 non terminal TypeName subtype_indication;
350 // 3.3.1 Object Declarations
351 non terminal List object_declaration;
352 non terminal List defining_identifier_list;
353 non terminal Variable.Kind object_qualifier_opt;
355 // 3.3.2 Number Declarations
356 non terminal List number_declaration;
359 non terminal Identifier name;
360 non terminal Identifier simple_name;
362 // 4.1.3 Selected Components
363 non terminal Identifier selected_component;
366 non terminal Expression expression;
367 non terminal Expression relation;
368 non terminal Expression simple_expression;
369 non terminal Expression term;
370 non terminal Expression factor;
371 non terminal Expression primary;
373 // 4.5 Operators and Expression Evaluation
374 non terminal InfixExpression.OperatorType logical_operator;
375 non terminal InfixExpression.OperatorType relational_operator;
376 non terminal InfixExpression.OperatorType binary_adding_operator;
377 non terminal UnaryOperation.Operator unary_adding_operator;
378 non terminal InfixExpression.OperatorType multiplying_operator;
380 // 4.7 Qualified Expressions
381 non terminal Expression qualified_expression;
383 // 5.1 Simple and Compound Statements - Sequences of Statements
384 non terminal List sequence_of_statements;
385 non terminal Statement simple_statement;
386 non terminal Statement compound_statement;
387 non terminal Statement null_statement;
389 // 5.2 Assignment Statements
390 non terminal Statement assignment_statement;
393 non terminal IfStatement if_statement;
394 non terminal List[] cond_clause_s;
395 non terminal Expression condition;
396 non terminal Block else_opt;
398 // 5.4 Case Statements
399 non terminal CaseStatement case_statement;
400 non terminal List alternative_s;
401 non terminal CaseWhen alternative;
403 // 5.5 Loop Statements
404 non terminal LoopStatement loop_statement;
405 non terminal Block basic_loop;
406 non terminal Expression iteration;
408 // 5.6 Block Statements
409 non terminal BlockStatement block_statement;
410 non terminal Block block_declarative;
411 non terminal Block block_body;
413 // 5.7 Exit Statements
414 non terminal Statement exit_statement;
415 non terminal Expression name_opt;
417 // 5.8 Goto Statements
418 non terminal Statement goto_statement;
420 // 6.1 Subprogram Declarations
421 non terminal SubprogramSpecification subprogram_specification;
422 non terminal SubprogramSpecification generic_subp_inst;
423 non terminal MethodDeclaration subprogram_body;
424 non terminal List param_s;
425 non terminal List formal_part_opt;
426 non terminal List formal_part;
427 non terminal List param;
428 non terminal FormalParameter.Mode mode;
429 non terminal Identifier designator;
430 non terminal Identifier operator_symbol;
432 // 6.5 Return Statements
433 non terminal Statement return_statement;
435 // 7.1 Package Specifications and Declarations
436 non terminal Statement package_declaration;
437 non terminal Statement package_specification;
439 // 7.2 Package Bodies
440 non terminal Statement package_body;
441 non terminal Statement body;
443 // 7.3 Private Types and Private Extensions
444 non terminal PrivateType private_type_declaration;
445 non terminal Integer tagged_opt;
446 non terminal Integer limited_opt;
449 non terminal Statement use_clause;
450 non terminal List package_name_list;
451 non terminal List subtype_mark_list;
453 // 8.5 Renaming Declarations
454 non terminal Statement renaming_declaration;
455 non terminal Statement rename_unit;
457 // 9.4 Protected Units and Protected Objects
458 non terminal Statement protected_body;
460 // 9.6 Delay Statements, Duration, and Time
461 non terminal Statement delay_statement;
463 // 9.8 Abort of a Task - Abort of a Sequence of Statements
464 non terminal Statement abort_statement;
465 non terminal List task_name_list;
467 // 10.1.1 Compilation Units - Library Units
468 non terminal Program compilation;
469 non terminal List compilation_units;
470 non terminal Statement compilation_unit;
471 non terminal Statement unit;
473 // 10.1.2 Context Clauses - With Clauses
474 non terminal Statement context_clause;
475 non terminal Statement with_clause;
476 non terminal List library_unit_name_list;
478 // 10.1.3 Subunits of Compilation Units
479 non terminal Statement body_stub;
481 // 11.3 Raise Statements
482 non terminal Statement raise_statement;
484 // 12.1 Generic Declarations
485 non terminal Statement generic_declaration;
487 // 13.8 Machine Code Insertions
488 non terminal Statement code_statement;
492 non terminal Identifier compound_name;
493 non terminal Identifier compound_name_opt;
494 non terminal TypeName object_subtype_def;
495 non terminal Expression init_opt;
496 non terminal Statement type_decl;
497 non terminal Expression type_completion;
498 non terminal NameBase subtype_mark;
499 non terminal List handled_stmt_s;
500 non terminal Statement statement;
501 non terminal Statement subunit;
502 non terminal Identifier id_opt;
503 non terminal Statement unlabeled;
504 non terminal Expression literal;
505 non terminal Expression parenthesized_primary;
506 non terminal Expression when_opt;
507 non terminal Statement procedure_call_statement;
508 non terminal String used_char;
509 non terminal Expression choice_s;
510 non terminal Identifier label_opt;
511 non terminal Identifier attribute;
512 non terminal Identifier indexed_component; // TODO: must be change it
513 non terminal Expression value_s;
514 non terminal Expression discrete_range;
515 non terminal Expression range;
516 non terminal InfixExpression.OperatorType short_circuit;
517 non terminal InfixExpression.OperatorType membership;
518 non terminal String attribute_id;
520 // TBD RM sections and types
522 non terminal pragma_arg_s;
523 non terminal pragma_arg;
524 non terminal pragma_s;
525 non terminal task_decl;
526 non terminal prot_decl;
527 non terminal exception_decl;
528 non terminal discrim_part_opt;
529 non terminal discrim_part;
530 non terminal enumeration_type;
531 non terminal integer_type;
532 non terminal real_type;
533 non terminal array_type;
534 non terminal record_type;
535 non terminal access_type;
536 non terminal derived_type;
537 non terminal constraint;
538 non terminal range_constraint;
539 non terminal decimal_digits_constraint;
540 non terminal range_constr_opt;
541 non terminal record_def;
542 non terminal enum_id_s;
543 non terminal enum_id;
544 non terminal range_spec;
545 non terminal range_spec_opt;
546 non terminal float_type;
547 non terminal fixed_type;
548 non terminal unconstr_array_type;
549 non terminal constr_array_type;
550 non terminal index_s;
552 non terminal component_subtype_def;
553 non terminal aliased_opt;
554 non terminal iter_index_constraint;
555 non terminal iter_discrete_range_s;
556 non terminal comp_list;
557 non terminal comp_decl_s;
558 non terminal comp_decl;
559 non terminal variant_part_opt;
560 non terminal variant_part;
561 non terminal discrim_spec_s;
562 non terminal discrim_spec;
563 non terminal access_opt;
564 non terminal variant_s;
565 non terminal variant;
567 non terminal discrete_with_range;
568 non terminal prot_opt;
569 non terminal rep_spec;
570 non terminal declarative_item_or_body;
572 non terminal comp_assoc;
573 non terminal aggregate;
574 non terminal value_s_2;
575 non terminal allocator;
577 non terminal requeue_stmt;
578 non terminal accept_stmt;
579 non terminal select_stmt;
580 non terminal iter_part;
581 non terminal reverse_opt;
582 non terminal except_handler_part_opt;
583 non terminal except_handler_part;
584 non terminal generic_package_instantiation;
585 non terminal body_opt;
586 non terminal generic_formal_part;
587 non terminal task_spec;
588 non terminal task_def;
589 non terminal entry_decl_s;
590 non terminal rep_spec_s;
591 non terminal task_private_opt;
592 non terminal prot_spec;
593 non terminal prot_def;
594 non terminal prot_op_decl_s;
595 non terminal prot_private_opt;
596 non terminal prot_elem_decl_s;
597 non terminal prot_op_decl;
598 non terminal entry_decl;
599 non terminal prot_elem_decl;
600 non terminal prot_op_body_s;
601 non terminal prot_op_body;
602 non terminal entry_body;
603 non terminal entry_body_part;
604 non terminal accept_hdr;
605 non terminal entry_call;
606 non terminal entry_name;
607 non terminal select_wait;
608 non terminal async_select;
609 non terminal timed_entry_call;
610 non terminal cond_entry_call;
611 non terminal guarded_select_alt;
612 non terminal or_select;
613 non terminal select_alt;
614 non terminal stmts_opt;
615 non terminal delay_or_entry_alt;
616 non terminal private_opt;
617 non terminal exception_handler;
618 non terminal except_choice_s;
619 non terminal except_choice;
620 non terminal generic_formal;
621 non terminal generic_discrim_part_opt;
622 non terminal generic_type_def;
623 non terminal subp_default;
624 non terminal generic_derived_type;
625 non terminal generic_inst;
626 non terminal attrib_def;
627 non terminal record_type_spec;
628 non terminal address_spec;
629 non terminal align_opt;
630 non terminal comp_loc_s;
632 /*************************
633 * JavaCup precedence *
634 *************************/
636 // TODO: must be complete
641 precedence left SEMICOLON;
643 precedence left ELSIF;
644 precedence left ELSE;
647 precedence right NOT;
649 precedence nonassoc ASSIGNMENT;
652 ///////////////////////////////////////////////////////////////////////////////
653 // start with root symbol
655 start with compilation;
663 ///////////////////////////////////////////////////////////////////////////////
666 pragma ::= PRAGMA IDENTIFIER SEMICOLON
667 | PRAGMA simple_name LPAREN pragma_arg_s RPAREN SEMICOLON
670 pragma_arg_s ::= pragma_arg
671 | pragma_arg_s COMMA pragma_arg
674 pragma_arg ::= expression
675 | simple_name ARROW expression
682 ///////////////////////////////////////////////////////////////////////////////
685 fields_declaration ::=
686 object_declaration:statement
690 | number_declaration:statement
701 | subtype_declaration:statement
711 | renaming_declaration:statement
715 | generic_declaration:statement
719 | body_stub:statement
723 | error:theError SEMICOLON // error statement
725 ASTError error = new ASTError(theErrorleft, theErrorright);
730 defining_identifier ::=
733 Identifier identifier = new Identifier(idleft, idright, id);
738 ///////////////////////////////////////////////////////////////////////////////
739 // 3.3.1 Object Declarations
741 object_declaration ::=
742 defining_identifier_list:identifierList COLON object_qualifier_opt:varKind object_subtype_def:subtype init_opt:init SEMICOLON
744 List list = new LinkedList();
745 for (Object identifier : identifierList) {
746 Variable variable = new Variable (((Identifier)identifier).getStartOffset(), ((Identifier)identifier).getEndOffset(), (Identifier)identifier, varKind, subtype);
747 list.add(new ASTNode[] {variable, init});
753 defining_identifier_list ::=
754 defining_identifier:identifier
756 List identifierList = new LinkedList();
757 identifierList.add(identifier);
758 RESULT = identifierList;
760 | defining_identifier_list:identifierList COMMA defining_identifier:identifier
762 identifierList.add(identifier);
763 RESULT = identifierList;
767 object_qualifier_opt ::=
769 RESULT = Variable.Kind.DEFAULT;
773 RESULT = Variable.Kind.ALIASED;
777 RESULT = Variable.Kind.CONSTANT;
781 RESULT = Variable.Kind.ALIASED_CONSTANT;
785 object_subtype_def ::=
786 subtype_indication:subtype
797 | ASSIGNMENT expression:expr
803 ///////////////////////////////////////////////////////////////////////////////
804 // 3.3.2 Number Declarations
806 number_declaration ::=
807 defining_identifier_list:identifierList COLON CONSTANT ASSIGNMENT expression:init SEMICOLON
809 List list = new LinkedList();
810 for (Object identifier : identifierList) {
811 Variable variable = new Variable (((Identifier)identifier).getStartOffset(), ((Identifier)identifier).getEndOffset(), (Identifier)identifier, Variable.Kind.CONSTANT);
812 list.add(new ASTNode[] {variable, init});
819 TYPE:token defining_identifier:identifier discrim_part_opt type_completion:typeCompletion SEMICOLON:end
821 TypeDeclaration type = new TypeDeclaration (tokenleft, endright, identifier, typeCompletion);
836 | IS type_definition:typeDef
850 | private_type_declaration:privateType
852 RESULT = privateType;
856 ///////////////////////////////////////////////////////////////////////////////
857 // 3.2.2 Subtype Declarations
859 subtype_declaration ::=
860 SUBTYPE:token defining_identifier:identifier IS subtype_indication:subtypeIndication SEMICOLON:end
862 SubtypeDeclaration type = new SubtypeDeclaration (tokenleft, endright, identifier, subtypeIndication);
867 subtype_indication ::=
870 TypeName type = new TypeName (nameleft, nameright, name);
875 TypeName type = new TypeName (nameleft, nameright, name);
880 constraint ::= range_constraint
881 | decimal_digits_constraint
884 decimal_digits_constraint ::= DIGITS expression range_constr_opt
887 derived_type ::= NEW subtype_indication
888 | NEW subtype_indication WITH PRIVATE
889 | NEW subtype_indication WITH record_def
890 | ABSTRACT NEW subtype_indication WITH PRIVATE
891 | ABSTRACT NEW subtype_indication WITH record_def
894 range_constraint ::= RANGE range
898 simple_expression:simple_expression1 DOT_DOT simple_expression:simple_expression2
900 Range range = new Range (simple_expression1left, simple_expression2right, simple_expression1, simple_expression2);
903 | name:name TICK RANGE:end
905 Range range = new Range (nameleft, endright, name, name);
908 | name:name TICK RANGE LPAREN expression:expression RPAREN:end
910 Range range = new Range (nameleft, endright, name, expression);
915 enumeration_type ::= LPAREN enum_id_s RPAREN
918 enum_id_s ::= enum_id
919 | enum_id_s COMMA enum_id
922 enum_id ::= IDENTIFIER
926 integer_type ::= range_spec
931 range_spec ::= range_constraint
938 real_type ::= float_type
942 float_type ::= DIGITS expression range_spec_opt
945 fixed_type ::= DELTA expression range_spec
946 | DELTA expression DIGITS expression range_spec_opt
949 array_type ::= unconstr_array_type
953 unconstr_array_type ::= ARRAY LPAREN index_s RPAREN OF component_subtype_def
956 constr_array_type ::= ARRAY iter_index_constraint OF component_subtype_def
959 component_subtype_def ::= aliased_opt subtype_indication
967 | index_s COMMA index
970 index ::= name RANGE BOX
973 iter_index_constraint ::= LPAREN iter_discrete_range_s RPAREN
976 iter_discrete_range_s ::= discrete_range
977 | iter_discrete_range_s COMMA discrete_range
981 name range_constr_opt
992 record_type ::= tagged_opt limited_opt record_def
995 record_def ::= RECORD pragma_s comp_list END RECORD
1005 RESULT = Ada95ASTParser.TAGGED;
1009 RESULT = Ada95ASTParser.TAGGED + Ada95ASTParser.ABSTRACT;
1013 comp_list ::= comp_decl_s variant_part_opt
1014 | variant_part pragma_s
1015 | NULL SEMICOLON pragma_s
1018 comp_decl_s ::= comp_decl
1019 | comp_decl_s pragma_s comp_decl
1022 variant_part_opt ::= pragma_s
1023 | pragma_s variant_part pragma_s
1027 defining_identifier_list COLON component_subtype_def init_opt SEMICOLON
1028 | error:theError SEMICOLON
1030 ASTError error = new ASTError(theErrorleft, theErrorright);
1035 discrim_part ::= LPAREN discrim_spec_s RPAREN
1038 discrim_spec_s ::= discrim_spec
1039 | discrim_spec_s SEMICOLON discrim_spec
1043 defining_identifier_list COLON access_opt subtype_mark init_opt
1044 | error:theError // error statement
1046 ASTError error = new ASTError(theErrorleft, theErrorright);
1055 variant_part ::= CASE simple_name IS pragma_s variant_s END CASE SEMICOLON
1058 variant_s ::= variant
1062 variant ::= WHEN choice_s ARROW pragma_s comp_list
1066 | choice_s BAR choice
1069 choice ::= expression
1070 | discrete_with_range
1074 discrete_with_range ::= name range_constraint
1078 access_type ::= ACCESS subtype_indication
1079 | ACCESS CONSTANT subtype_indication
1080 | ACCESS ALL subtype_indication
1081 | ACCESS prot_opt PROCEDURE formal_part_opt
1082 | ACCESS prot_opt FUNCTION formal_part_opt RETURN subtype_mark
1089 ///////////////////////////////////////////////////////////////////////////////
1090 // 3.11 Declarative Parts
1092 declarative_part ::=
1094 RESULT = new LinkedList();
1096 | declarative_item_or_body_s1:statement
1102 declarative_items_opt ::=
1105 RESULT = new LinkedList();
1107 | declarative_item_list:declaritiveItemList
1109 RESULT = declaritiveItemList;
1113 declarative_item_list ::=
1114 declarative_item:declaritiveItem
1116 List declaritiveItemList = new LinkedList();
1117 declaritiveItemList.add(declaritiveItem);
1118 RESULT = declaritiveItemList;
1120 | declarative_item_list:declaritiveItemList declarative_item:declaritiveItem
1122 declaritiveItemList.add(declaritiveItem);
1123 RESULT = declaritiveItemList;
1127 declarative_item ::=
1128 fields_declaration:list
1130 FieldsDeclaration fieldsDeclaration = new FieldsDeclaration(listleft, listright, list);
1131 RESULT = fieldsDeclaration;
1133 | type_declaration:statement
1137 | subprog_declaration:statement
1141 | package_declaration:statement
1145 | declaration:statement // todo: to be split
1149 | use_clause:statement
1157 declarative_item_or_body_s1 ::=
1158 declarative_item_or_body:declaritiveItem
1160 List declaritiveItemList = new LinkedList();
1161 declaritiveItemList.add(declaritiveItem);
1162 RESULT = declaritiveItemList;
1164 | declarative_item_or_body_s1:declaritiveItemList declarative_item_or_body:declaritiveItem
1166 declaritiveItemList.add(declaritiveItem);
1167 RESULT = declaritiveItemList;
1171 declarative_item_or_body ::=
1176 | declarative_item:statement
1183 subprogram_body:statement
1187 | package_body:statement
1191 | task_body:statement
1195 | protected_body:statement
1202 subprogram_body:statement
1206 | package_body:statement
1210 | task_body:statement
1214 | protected_body:statement
1221 simple_name:simple_name // direct_name
1223 RESULT = simple_name;
1225 | operator_symbol:operator_symbol // direct_name
1227 RESULT = operator_symbol;
1229 | indexed_component:indexed_component
1231 RESULT = indexed_component;
1233 | selected_component:selected_component
1235 RESULT = selected_component;
1237 | attribute:attribute
1246 TypeName typeName = new TypeName (nameleft, nameright, name);
1249 | subtype_mark:name TICK attribute_id:id
1251 ((TypeName)name).setAttributeId(id);
1254 | subtype_mark:subtype_mark DOT simple_name:simple_name
1257 TypeName typeName = new TypeName (simple_nameleft, simple_nameright, simple_name);
1258 if (subtype_mark instanceof TypeName) {
1259 PackageName packageName = new PackageName (subtype_markleft, subtype_markright, ((TypeName)subtype_mark).getTypeName());
1260 dispatch = parser.createDispatch(packageName, typeName);
1262 dispatch = parser.createDispatch(subtype_mark, typeName);
1272 Identifier identifier = new Identifier (idleft, idright, id);
1273 RESULT = identifier;
1277 // TODO: must be create a list of identifiers
1279 simple_name:simple_name
1281 RESULT = simple_name;
1283 | compound_name:compound_name DOT simple_name:simple_name
1285 RESULT = simple_name;
1289 library_unit_name_list ::=
1290 compound_name:compound_name
1292 List nameList = new LinkedList();
1293 PackageName packageName = new PackageName(compound_nameleft, compound_nameright, compound_name);
1294 nameList.add(packageName);
1297 | library_unit_name_list:nameList COMMA compound_name:compoundName
1299 nameList.add(compoundName);
1305 CHAR_LITERAL:charLiteral
1307 RESULT = charLiteral;
1311 indexed_component ::=
1312 name:name LPAREN value_s:index RPAREN:end
1319 | value_s COMMA value
1322 value ::= expression
1324 | discrete_with_range
1325 | error:theError /* error statement */
1327 ASTError error = new ASTError(theErrorleft, theErrorright);
1332 ///////////////////////////////////////////////////////////////////////////////
1333 // 4.1.3 Selected Components
1335 selected_component ::=
1336 name:name DOT simple_name:simple_name
1338 Identifier identifier = new Identifier (nameleft, simple_nameright, name.getName() + "." + simple_name.getName());
1339 RESULT = identifier;
1341 | name:name DOT used_char:used_char
1343 Identifier identifier = new Identifier (nameleft, used_charright, name.getName() + "." + used_char);
1344 RESULT = identifier;
1346 | name:name DOT operator_symbol:operator
1348 Identifier identifier = new Identifier (nameleft, operatorright, name.getName() + "." + operator.getName());
1349 RESULT = identifier;
1351 | name:name DOT ALL:all
1353 Identifier identifier = new Identifier (nameleft, allright, name.getName() + "." + "all");
1354 RESULT = identifier;
1359 name:name TICK attribute_id
1375 Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
1380 Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
1383 | used_char:usedChar
1385 Scalar scalar = new Scalar(usedCharleft, usedCharright, usedChar, Scalar.Type.STRING);
1390 Scalar scalar = new Scalar(tokenleft, tokenright, "null", Scalar.Type.SYSTEM);
1395 aggregate ::= LPAREN comp_assoc RPAREN
1396 | LPAREN value_s_2 RPAREN
1397 | LPAREN expression WITH value_s RPAREN
1398 | LPAREN expression WITH NULL RECORD RPAREN
1399 | LPAREN NULL RECORD RPAREN
1402 value_s_2 ::= value COMMA value
1403 | value_s_2 COMMA value
1406 comp_assoc ::= choice_s ARROW expression
1410 ///////////////////////////////////////////////////////////////////////////////
1411 // 4.5 Operators and Expression Evaluation
1413 logical_operator ::=
1416 RESULT = InfixExpression.OperatorType.BOOL_AND;
1420 RESULT = InfixExpression.OperatorType.BOOL_OR;
1424 RESULT = InfixExpression.OperatorType.BOOL_XOR;
1431 RESULT = InfixExpression.OperatorType.BOOL_OR;
1435 RESULT = InfixExpression.OperatorType.BOOL_AND;
1439 relational_operator ::=
1442 RESULT = InfixExpression.OperatorType.IS_EQUAL;
1446 RESULT = InfixExpression.OperatorType.IS_NOT_EQUAL;
1450 RESULT = InfixExpression.OperatorType.RGREATER;
1454 RESULT = InfixExpression.OperatorType.IS_SMALLER_OR_EQUAL;
1458 RESULT = InfixExpression.OperatorType.LGREATER;
1462 RESULT = InfixExpression.OperatorType.IS_GREATER_OR_EQUAL;
1469 RESULT = InfixExpression.OperatorType.IN;
1473 RESULT = InfixExpression.OperatorType.NOT_IN;
1477 unary_adding_operator ::=
1480 RESULT = UnaryOperation.Operator.PLUS;
1484 RESULT = UnaryOperation.Operator.MINUS;
1488 binary_adding_operator ::=
1491 RESULT = InfixExpression.OperatorType.PLUS;
1495 RESULT = InfixExpression.OperatorType.MINUS;
1499 RESULT = InfixExpression.OperatorType.STRING_AND;
1503 multiplying_operator ::=
1506 RESULT = InfixExpression.OperatorType.MUL;
1510 RESULT = InfixExpression.OperatorType.DIV;
1514 RESULT = InfixExpression.OperatorType.MOD;
1518 RESULT = InfixExpression.OperatorType.REM;
1522 ///////////////////////////////////////////////////////////////////////////////
1530 | expression:expression logical_operator:logical_operator relation:relation
1532 InfixExpression infixExpression = new InfixExpression(expressionleft, relationright, expression, logical_operator, relation);
1533 RESULT = infixExpression;
1535 | expression:expression short_circuit:short_circuit relation:relation
1537 InfixExpression infixExpression = new InfixExpression(expressionleft, relationright, expression, short_circuit, relation);
1538 RESULT = infixExpression;
1543 simple_expression:simple_expression
1545 RESULT = simple_expression;
1547 | simple_expression:simple_expression1 relational_operator:relational_operator simple_expression:simple_expression2
1549 InfixExpression infixExpression = new InfixExpression(simple_expression1left, simple_expression2right, simple_expression1, relational_operator, simple_expression2);
1550 RESULT = infixExpression;
1552 | simple_expression:simple_expression membership:membership range:range
1554 InfixExpression infixExpression = new InfixExpression(simple_expressionleft, rangeright, simple_expression, membership, range);
1555 RESULT = infixExpression;
1557 | simple_expression:simple_expression membership:membership name:name
1559 InfixExpression infixExpression = new InfixExpression(simple_expressionleft, nameright, simple_expression, membership, name);
1560 RESULT = infixExpression;
1564 simple_expression ::=
1565 unary_adding_operator:unary_adding_operator term:term
1567 UnaryOperation unaryOperation = new UnaryOperation(unary_adding_operatorleft, termright, term, unary_adding_operator);
1568 RESULT = unaryOperation;
1574 | simple_expression:simple_expression binary_adding_operator:binary_adding_operator term:term
1576 InfixExpression infixExpression = new InfixExpression(simple_expressionleft, termright, simple_expression, binary_adding_operator, term);
1577 RESULT = infixExpression;
1586 | term:term multiplying_operator:multiplying_operator factor:factor
1588 InfixExpression infixExpression = new InfixExpression(termleft, factorright, term, multiplying_operator, factor);
1589 RESULT = infixExpression;
1598 | NOT:token primary:primary
1600 UnaryOperation unaryOperation = new UnaryOperation(tokenleft, primaryright, primary, UnaryOperation.Operator.NOT);
1601 RESULT = unaryOperation;
1603 | ABS:token primary:primary
1605 UnaryOperation unaryOperation = new UnaryOperation(tokenleft, primaryright, primary, UnaryOperation.Operator.ABS);
1606 RESULT = unaryOperation;
1608 | primary:primary1 EXPON primary:primary2
1610 InfixExpression infixExpression = new InfixExpression(primary1left, primary2right, primary1, InfixExpression.OperatorType.EXPON, primary2);
1611 RESULT = infixExpression;
1622 // TODO: must be modified for manage all primery types
1623 Variable variable = new Variable (nameleft, nameright, name);
1627 | qualified_expression:qualified_expression
1629 RESULT = qualified_expression;
1631 | parenthesized_primary:parenthesized_primary
1633 RESULT = parenthesized_primary;
1637 parenthesized_primary ::=
1639 | LPAREN expression:expression RPAREN
1641 RESULT = expression;
1645 qualified_expression ::=
1646 name:name TICK parenthesized_primary:expr
1648 RESULT = new QualifiedExpression (nameleft, exprright, name, expr);
1652 allocator ::= NEW name
1653 | NEW qualified_expression
1656 ///////////////////////////////////////////////////////////////////////////////
1657 // 5.1 Simple and Compound Statements - Sequences of Statements
1659 sequence_of_statements ::=
1662 List list = new LinkedList();
1663 list.add(statement);
1666 | sequence_of_statements:list statement:statement
1668 list.add(statement);
1678 | label statement:statement
1685 simple_statement:statement
1689 | compound_statement:statement
1696 simple_statement ::=
1697 null_statement:statement
1701 | assignment_statement:statement
1705 | exit_statement:statement
1709 | return_statement:statement
1713 | goto_statement:statement
1717 | procedure_call_statement:statement
1721 | delay_statement:statement
1725 | abort_statement:statement
1729 | raise_statement:statement
1733 | code_statement:statement
1738 | error:theError SEMICOLON /* error statement */
1740 ASTError error = new ASTError(theErrorleft, theErrorright);
1745 compound_statement ::=
1746 if_statement:statement
1750 | case_statement:statement
1754 | loop_statement:statement
1758 | block_statement:statement
1766 label ::= LTLT IDENTIFIER GTGT
1770 NULL:token SEMICOLON:end
1772 RESULT = new NullStatement(tokenleft, endright);
1776 ///////////////////////////////////////////////////////////////////////////////
1777 // 5.2 Assignment Statements
1779 assignment_statement ::=
1780 name:name ASSIGNMENT expression:expression SEMICOLON
1782 Variable variable = new Variable (nameleft, nameright, name);
1783 Assignment assignment = new Assignment(nameleft, expressionright, variable, expression);
1784 RESULT = assignment;
1788 ///////////////////////////////////////////////////////////////////////////////
1789 // 5.3 If Statements
1792 IF:token cond_clause_s:condList else_opt:iffalse END IF SEMICOLON:end
1794 Expression innerCondition = null;
1795 Expression firstCondition = null;
1796 Statement trueStatement = null;
1797 Statement falseStatement = iffalse;
1799 for (int i=1 ; i < condList[0].size() ; i++) {
1800 innerCondition = (Expression)condList[0].get(i);
1801 trueStatement = (Statement)condList[1].get(i);
1802 int start = ((Integer)condList[2].get(i)).intValue();
1803 falseStatement = new IfStatement(start, endright, innerCondition, trueStatement, falseStatement);
1806 firstCondition = (Expression)condList[0].get(0);
1807 trueStatement = (Statement)condList[1].get(0);
1808 int start = ((Integer)condList[2].get(0)).intValue();
1809 IfStatement ifStatement = new IfStatement(tokenleft, endright, firstCondition, trueStatement, falseStatement);
1811 RESULT = ifStatement;
1816 condition:condition THEN:token sequence_of_statements:iftrue
1818 List listConditions = new LinkedList();
1819 List listStatements = new LinkedList();
1820 List listTokens = new LinkedList();
1822 Block block = new Block(iftrueleft, iftrueright, iftrue);
1823 listConditions.add(condition);
1824 listStatements.add(block);
1825 listTokens.add(new Integer(tokenleft));
1827 List[] returnList = new List[] { listConditions, listStatements, listTokens };
1829 RESULT = returnList;
1831 | cond_clause_s:condList ELSIF:token condition:condition THEN sequence_of_statements:iftrue
1833 Block block = new Block(iftrueleft, iftrueright, iftrue);
1834 ((LinkedList)condList[0]).addFirst(condition);
1835 ((LinkedList)condList[1]).addFirst(block);
1836 ((LinkedList)condList[2]).addFirst(new Integer(tokenleft));
1843 expression:expression
1845 RESULT = expression;
1854 | ELSE sequence_of_statements:statements
1856 Block block = new Block(statementsleft, statementsright, statements);
1861 ///////////////////////////////////////////////////////////////////////////////
1862 // 5.4 Case Statements
1865 CASE:token expression:expr IS pragma_s alternative_s:whenList END CASE SEMICOLON:end
1867 Block whenBlock = new Block(whenListleft, whenListright, whenList);
1868 CaseStatement caseStatement = new CaseStatement(tokenleft, endright, expr, whenBlock);
1869 RESULT = caseStatement;
1876 RESULT = new LinkedList();
1878 | alternative_s:whenList alternative:when
1880 whenList.add (when);
1886 WHEN:token choice_s:expr ARROW sequence_of_statements:statements
1888 CaseWhen caseWhen = new CaseWhen(tokenleft, statementsright, expr, statements);
1893 ///////////////////////////////////////////////////////////////////////////////
1894 // 5.5 Loop Statements
1897 label_opt:label iteration:iteration basic_loop:statement id_opt SEMICOLON:end
1899 int start = (label == null) ? iterationleft : labelleft;
1900 LoopStatement loopStatement = new LoopStatement(start, endright, label, iteration, statement);
1901 RESULT = loopStatement;
1910 | IDENTIFIER:id COLON
1912 Identifier identifier = new Identifier (idleft, idright, id);
1913 RESULT = identifier;
1922 | WHILE condition:condition
1926 | iter_part reverse_opt discrete_range:condition
1941 LOOP sequence_of_statements:statements END LOOP
1943 Block loopBlock = new Block(statementsleft, statementsright, statements);
1949 ///////////////////////////////////////////////////////////////////////////////
1956 | designator:designator
1958 RESULT = designator;
1962 ///////////////////////////////////////////////////////////////////////////////
1963 // 5.6 Block Statements
1966 label_opt:label block_declarative:declarations block_body:body END id_opt SEMICOLON:end
1968 int start = (label == null) ? declarationsleft : labelleft;
1969 BlockStatement blockStatement = new BlockStatement (start, endleft, label, declarations, body);
1970 RESULT = blockStatement;
1974 block_declarative ::=
1978 | DECLARE:token declarative_part:declarativePart
1980 Block declarations = new Block(tokenright, declarativePartleft, declarativePart);
1981 RESULT = declarations;
1986 BEGIN:token handled_stmt_s:statements
1988 Block body = new Block(tokenright, statementsright, statements);
1994 sequence_of_statements:statements except_handler_part_opt
1996 RESULT = statements;
2000 except_handler_part_opt ::=
2001 | except_handler_part
2004 ///////////////////////////////////////////////////////////////////////////////
2005 // 5.7 Exit Statements
2008 EXIT:token name_opt:loopName when_opt:whenCondition SEMICOLON:end
2010 RESULT = new ExitStatement(tokenleft, endright, loopName, whenCondition);
2028 | WHEN condition:cond
2034 ///////////////////////////////////////////////////////////////////////////////
2035 // 6.5 Return Statements
2037 return_statement ::=
2038 RETURN:token SEMICOLON:end
2040 RESULT = new ReturnStatement(tokenleft, endright);
2042 | RETURN:token expression:expr SEMICOLON:end
2044 RESULT = new ReturnStatement(tokenleft, endright, expr);
2048 ///////////////////////////////////////////////////////////////////////////////
2049 // 5.8 Goto Statements
2052 GOTO:token name:labelName SEMICOLON:end
2054 RESULT = new GotoStatement(tokenleft, endright, labelName);
2058 ///////////////////////////////////////////////////////////////////////////////
2059 // 6.1 Subprogram Declarations
2061 subprog_declaration ::=
2062 subprogram_specification:subprog SEMICOLON:end
2064 RESULT = new MethodDeclaration(subprogleft, endright, 0/*modifier*/, subprog);
2066 | generic_subp_inst:subprog SEMICOLON:end
2068 RESULT = new MethodDeclaration(subprogleft, endright, 0/*modifier*/, subprog);
2070 | subprogram_specification:subprog IS ABSTRACT SEMICOLON:end
2072 RESULT = new MethodDeclaration(subprogleft, endright, Ada95ASTParser.ABSTRACT, subprog);
2076 subprogram_specification ::=
2077 PROCEDURE:procedure compound_name:compound_name formal_part_opt:formal_part
2079 SubprogramSpecification subprogramSpecification = new SubprogramSpecification(procedureleft, formal_partright, compound_name, formal_part);
2080 RESULT = subprogramSpecification;
2082 | FUNCTION:function designator:designator formal_part_opt:formal_part RETURN name:subtype_mark
2084 SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, subtype_markright, designator, formal_part, subtype_mark);
2085 RESULT = subprogramSpecification;
2087 | FUNCTION:function designator:designator /* for generic inst and generic rename */
2089 SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, designatorright, designator);
2090 RESULT = subprogramSpecification;
2099 | operator_symbol:name
2108 List list = new LinkedList();
2118 LPAREN param_s:list RPAREN
2127 List list = new LinkedList();
2128 list.addAll(parameter);
2131 | param_s:list SEMICOLON param:parameter
2133 list.addAll(parameter);
2139 defining_identifier_list:identifierList COLON mode:mode subtype_mark:subtype init_opt:init
2141 List list = new LinkedList();
2142 for (Object item : identifierList) {
2143 Identifier identifier = (Identifier)item;
2144 Variable variable = new Variable (identifier.getStartOffset(), identifier.getEndOffset(), identifier);
2145 int end = init == null ? subtyperight : initright;
2146 FormalParameter parameter = new FormalParameter(identifierListleft, end, variable, mode, subtype, init);
2147 list.add(parameter);
2151 | error:theError SEMICOLON /* error statement */
2153 List list = new LinkedList();
2154 ASTError error = new ASTError(theErrorleft, theErrorright);
2163 RESULT = FormalParameter.Mode.IN;
2167 RESULT = FormalParameter.Mode.IN;
2171 RESULT = FormalParameter.Mode.OUT;
2175 RESULT = FormalParameter.Mode.IN_OUT;
2179 RESULT = FormalParameter.Mode.ACCESS;
2183 // TODO: manage the overload operators ex: "+" "and" ecc.
2185 STRING_LITERAL:string_literal
2187 Identifier identifier = new Identifier (string_literalleft, string_literalright, string_literal);
2188 RESULT = identifier;
2193 subprogram_specification:subprog IS
2194 declarative_part:declarativePart block_body:body END id_opt:id_opt SEMICOLON:end
2196 if (id_opt != null && !id_opt.getName().equalsIgnoreCase (subprog.getSubprogramName().getName())) {
2197 this.parser.message_error("mispelling of " + subprog.getSubprogramName().getName());
2199 Block declarations = new Block(subprogright, bodyleft, declarativePart);
2200 body.setEndOffset(endright);
2201 SubprogramBody subprogramBody = new SubprogramBody(subprogleft, endright, subprog, declarations, body, id_opt);
2202 MethodDeclaration methodDeclaration = new MethodDeclaration(subprogleft, endright, 0/*modifier*/, subprogramBody);
2203 RESULT = methodDeclaration;
2208 ///////////////////////////////////////////////////////////////////////////////
2209 // 6.4 Subprogram Calls
2211 procedure_call_statement ::=
2216 ///////////////////////////////////////////////////////////////////////////////
2217 // 7.1 Package Specifications and Declarations
2219 package_declaration ::=
2220 package_specification:statement SEMICOLON
2224 | generic_package_instantiation SEMICOLON
2227 package_specification ::=
2228 PACKAGE:declarationStart compound_name:package_name IS:blockStart
2229 declarative_items_opt:declarativeItems private_part:privateDeclarativeItems
2230 END:declarationEnd compound_name_opt:package_name_end
2232 if (package_name_end != null && !package_name_end.getName().equalsIgnoreCase (package_name.getName())) {
2233 this.parser.message_error("mispelling of " + package_name);
2236 declarativeItems.addAll (privateDeclarativeItems);
2237 // Add private part on block statements
2238 Block block = new Block(blockStartleft, declarationEndright, declarativeItems);
2239 PackageSpecification packageSpecification = new PackageSpecification(declarationStartleft, declarationEndright, package_name, package_name_end, block);
2240 RESULT = packageSpecification;
2247 RESULT = new LinkedList();
2249 | PRIVATE declarative_items_opt:declarativeItems
2251 RESULT = this.parser.setModifier (declarativeItems, Ada95ASTParser.PRIVATE);
2255 compound_name_opt ::=
2257 | compound_name:compound_name
2259 RESULT = compound_name;
2263 ///////////////////////////////////////////////////////////////////////////////
2264 // 7.2 Package Bodies
2267 PACKAGE:declarationStart BODY compound_name:package_name IS:blockStart
2268 declarative_part:declarativePart body_opt END compound_name_opt:package_name_end SEMICOLON:declarationEnd
2270 if (package_name_end != null && !package_name_end.getName().equalsIgnoreCase (package_name.getName())) {
2271 this.parser.message_error("mispelling of " + package_name);
2275 List list = this.parser.setModifier (declarativePart, Ada95ASTParser.PRIVATE);
2276 Block block = new Block(blockStartleft, declarationEndright, list);
2278 PackageBody packageBody = new PackageBody(declarationStartleft, declarationEndright, package_name, package_name_end, block);
2279 RESULT = packageBody;
2288 ///////////////////////////////////////////////////////////////////////////////
2289 // 7.3 Private Types and Private Extensions
2291 private_type_declaration ::=
2292 tagged_opt:tagged limited_opt:limited PRIVATE:privateKeyword
2294 PrivateType privateType = new PrivateType(taggedleft, privateKeywordright, tagged + limited + Ada95ASTParser.PRIVATE);
2295 RESULT = privateType;
2305 RESULT = Ada95ASTParser.LIMITED;
2309 ///////////////////////////////////////////////////////////////////////////////
2313 USE:token package_name_list:packageList SEMICOLON:end
2315 RESULT = new Use(tokenleft, endright, packageList);
2317 | USE:token TYPE subtype_mark_list:subTypeList SEMICOLON:end
2319 RESULT = new UseType(tokenleft, endright, subTypeList);
2323 package_name_list ::=
2326 List idList = new LinkedList();
2327 PackageName packageName = new PackageName(nameleft, nameright, name);
2328 idList.add(packageName);
2331 | package_name_list:idList COMMA name:name
2333 PackageName packageName = new PackageName(nameleft, nameright, name);
2334 idList.add(packageName);
2339 subtype_mark_list ::=
2342 List idList = new LinkedList();
2343 TypeName typeName = new TypeName(nameleft, nameright, name);
2344 idList.add(typeName);
2347 | subtype_mark_list:idList COMMA name:name
2349 TypeName typeName = new TypeName(nameleft, nameright, name);
2350 idList.add(typeName);
2356 ///////////////////////////////////////////////////////////////////////////////
2357 // 8.5 Renaming Declarations
2359 renaming_declaration ::=
2360 defining_identifier_list COLON object_qualifier_opt subtype_indication RENAMES name SEMICOLON
2361 | defining_identifier_list COLON EXCEPTION RENAMES name SEMICOLON
2369 PACKAGE:token compound_name:name RENAMES name:renames SEMICOLON:end
2371 PackageRenames packageRenames = new PackageRenames(tokenleft, endright, name, renames);
2372 RESULT = packageRenames;
2374 | subprogram_specification RENAMES name SEMICOLON:end
2375 | generic_formal_part PACKAGE compound_name RENAMES name SEMICOLON
2376 | generic_formal_part subprogram_specification RENAMES name SEMICOLON
2379 task_decl ::= task_spec SEMICOLON
2382 task_spec ::= TASK simple_name task_def
2383 | TASK TYPE simple_name discrim_part_opt task_def
2387 | IS entry_decl_s rep_spec_s task_private_opt END id_opt
2390 task_private_opt ::=
2391 | PRIVATE entry_decl_s rep_spec_s
2394 task_body ::= TASK BODY simple_name IS
2395 declarative_part block_body END id_opt SEMICOLON
2398 prot_decl ::= prot_spec SEMICOLON
2401 prot_spec ::= PROTECTED IDENTIFIER prot_def
2402 | PROTECTED TYPE simple_name discrim_part_opt prot_def
2405 prot_def ::= IS prot_op_decl_s prot_private_opt END id_opt
2408 prot_private_opt ::=
2409 | PRIVATE prot_elem_decl_s
2413 | prot_op_decl_s prot_op_decl
2416 prot_op_decl ::= entry_decl
2417 | subprogram_specification SEMICOLON
2422 prot_elem_decl_s ::=
2423 | prot_elem_decl_s prot_elem_decl
2426 prot_elem_decl ::= prot_op_decl | comp_decl ;
2428 /////////////////////////////////////////////////////////////////
2429 // 9.4 Protected Units and Protected Objects
2432 PROTECTED BODY simple_name:name IS
2433 prot_op_body_s END id_opt SEMICOLON
2436 prot_op_body_s ::= pragma_s
2437 | prot_op_body_s prot_op_body pragma_s
2440 prot_op_body ::= entry_body
2442 | subprogram_specification SEMICOLON
2445 entry_decl_s ::= pragma_s
2446 | entry_decl_s entry_decl pragma_s
2449 entry_decl ::= ENTRY IDENTIFIER formal_part_opt SEMICOLON
2450 | ENTRY IDENTIFIER LPAREN discrete_range RPAREN formal_part_opt SEMICOLON
2453 entry_body ::= ENTRY IDENTIFIER formal_part_opt WHEN condition entry_body_part
2454 | ENTRY IDENTIFIER LPAREN iter_part discrete_range RPAREN
2455 formal_part_opt WHEN condition entry_body_part
2458 entry_body_part ::= SEMICOLON
2459 | IS declarative_part block_body END id_opt SEMICOLON
2463 | rep_spec_s rep_spec pragma_s
2467 procedure_call_statement:statement
2473 accept_stmt ::= accept_hdr SEMICOLON
2474 | accept_hdr DO handled_stmt_s END id_opt SEMICOLON
2477 accept_hdr ::= ACCEPT entry_name formal_part_opt
2480 entry_name ::= simple_name
2481 | entry_name LPAREN expression RPAREN
2484 /////////////////////////////////////////////////////////////////
2485 // 9.6 Delay Statements, Duration, and Time
2488 DELAY:token expression:expr SEMICOLON:end
2490 RESULT = new ReturnStatement(tokenleft, endright, expr);
2492 | DELAY:token UNTIL expression:expr SEMICOLON:end
2494 RESULT = new ReturnStatement(tokenleft, endright, expr);
2498 select_stmt ::= select_wait
2504 select_wait ::= SELECT guarded_select_alt or_select else_opt
2505 END SELECT SEMICOLON
2508 guarded_select_alt ::= select_alt
2509 | WHEN condition ARROW select_alt
2513 | or_select OR guarded_select_alt
2516 select_alt ::= accept_stmt stmts_opt
2517 | delay_statement stmts_opt
2518 | TERMINATE SEMICOLON
2521 delay_or_entry_alt ::= delay_statement stmts_opt
2522 | entry_call stmts_opt
2525 async_select ::= SELECT delay_or_entry_alt
2526 THEN ABORT sequence_of_statements
2527 END SELECT SEMICOLON
2530 timed_entry_call ::= SELECT entry_call stmts_opt
2531 OR delay_statement stmts_opt
2532 END SELECT SEMICOLON
2535 cond_entry_call ::= SELECT entry_call stmts_opt
2536 ELSE sequence_of_statements
2537 END SELECT SEMICOLON
2541 | sequence_of_statements
2544 ///////////////////////////////////////////////////////////////////////////////
2545 // 9.8 Abort of a Task - Abort of a Sequence of Statements
2548 ABORT:token task_name_list:taskList SEMICOLON:end
2550 RESULT = new AbortStatement(tokenleft, endright, taskList);
2557 List idList = new LinkedList();
2558 TaskName taskName = new TaskName(nameleft, nameright, name);
2559 idList.add(taskName);
2562 | task_name_list:idList COMMA name:name
2564 TaskName taskName = new TaskName(nameleft, nameright, name);
2565 idList.add(taskName);
2570 ///////////////////////////////////////////////////////////////////////////////
2571 // 10.1.1 Compilation Units - Library Units
2574 compilation_units:units
2576 Ada95ASTLexer adaAstLexer = (Ada95ASTLexer) parser.getScanner();
2577 List comments = adaAstLexer.getCommentList();
2578 Program program = new Program(unitsleft, unitsright, units, comments);
2583 compilation_units ::=
2585 RESULT = new LinkedList();
2587 | compilation_units:units compilation_unit:unit
2594 | pragma pragma_s // 10.1.5 - 4
2596 RESULT = new LinkedList();
2600 compilation_unit ::=
2601 context_clause private_opt unit:unit pragma_s
2605 | private_opt unit:unit pragma_s // 10.1.5 - 5/1
2616 package_declaration:statement
2620 | package_body:statement
2624 | subprog_declaration:statement
2628 | subprogram_body:statement
2636 | generic_declaration:statement
2643 ///////////////////////////////////////////////////////////////////////////////
2644 // 10.1.2 Context Clauses - With Clauses
2647 with_clause:statement
2651 | use_clause:statement
2655 | context_clause with_clause:statement
2659 | context_clause use_clause:statement
2663 | context_clause pragma
2667 WITH:token library_unit_name_list:packageList SEMICOLON:end
2669 RESULT = new With(tokenleft, endright, packageList);
2673 ///////////////////////////////////////////////////////////////////////////////
2674 // 10.1.3 Subunits of Compilation Units
2677 SEPARATE LPAREN compound_name RPAREN
2678 proper_body:statement
2686 TASK BODY simple_name IS SEPARATE SEMICOLON
2687 | PACKAGE BODY compound_name IS SEPARATE SEMICOLON
2688 | subprogram_specification:subprog IS SEPARATE SEMICOLON
2692 | PROTECTED BODY simple_name IS SEPARATE SEMICOLON
2695 exception_decl ::= defining_identifier_list COLON EXCEPTION SEMICOLON
2698 except_handler_part ::= EXCEPTION exception_handler
2699 | except_handler_part exception_handler
2702 exception_handler ::= WHEN except_choice_s ARROW sequence_of_statements
2703 | WHEN IDENTIFIER COLON except_choice_s ARROW sequence_of_statements
2706 except_choice_s ::= except_choice
2707 | except_choice_s BAR except_choice
2710 except_choice ::= name
2714 ///////////////////////////////////////////////////////////////////////////////
2715 // 11.3 Raise Statements
2718 RAISE:token name_opt:exceptionName SEMICOLON:end
2720 RESULT = new RaiseStatement(tokenleft, endright, exceptionName);
2724 requeue_stmt ::= REQUEUE name SEMICOLON
2725 | REQUEUE name WITH ABORT SEMICOLON
2728 ///////////////////////////////////////////////////////////////////////////////
2729 // 12.1 Generic Declarations
2731 generic_declaration ::=
2732 generic_formal_part subprogram_specification SEMICOLON
2733 | generic_formal_part package_specification:statement SEMICOLON
2739 generic_formal_part ::= GENERIC
2740 | generic_formal_part generic_formal
2743 generic_formal ::= param SEMICOLON
2744 | TYPE simple_name generic_discrim_part_opt IS generic_type_def SEMICOLON
2745 | WITH PROCEDURE simple_name
2746 formal_part_opt subp_default SEMICOLON
2747 | WITH FUNCTION designator
2748 formal_part_opt RETURN name subp_default SEMICOLON
2749 | WITH PACKAGE simple_name IS NEW name LPAREN BOX RPAREN SEMICOLON
2750 | WITH PACKAGE simple_name IS NEW name SEMICOLON
2754 generic_discrim_part_opt ::=
2764 generic_type_def ::= LPAREN BOX RPAREN
2768 | DELTA BOX DIGITS BOX
2772 | private_type_declaration
2773 | generic_derived_type
2776 generic_derived_type ::= NEW subtype_indication
2777 | NEW subtype_indication WITH PRIVATE
2778 | ABSTRACT NEW subtype_indication WITH PRIVATE
2781 generic_subp_inst ::=
2782 subprogram_specification:subprog IS generic_inst
2789 generic_package_instantiation ::=
2790 PACKAGE compound_name IS generic_inst
2793 generic_inst ::= NEW name
2796 rep_spec ::= attrib_def
2801 attrib_def ::= FOR subtype_mark USE expression SEMICOLON
2804 record_type_spec ::= FOR subtype_mark USE RECORD align_opt comp_loc_s END RECORD SEMICOLON
2808 | AT MOD expression SEMICOLON
2812 | comp_loc_s subtype_mark AT expression RANGE range SEMICOLON
2815 address_spec ::= FOR subtype_mark USE AT expression SEMICOLON
2818 ///////////////////////////////////////////////////////////////////////////////
2819 // 13.8 Machine Code Insertions
2822 qualified_expression:expr SEMICOLON:end
2824 RESULT = new CodeStatement (exprleft, endright, expr);