ada.editor/src/org/netbeans/modules/ada/editor/parser/resources/Ada95ASTParser.cup
branchrelease68
changeset 16367 d2820c029d3a
parent 15779 367c7fdb5d23
     1.1 --- a/ada.editor/src/org/netbeans/modules/ada/editor/parser/resources/Ada95ASTParser.cup	Wed Sep 23 02:06:44 2009 +0200
     1.2 +++ b/ada.editor/src/org/netbeans/modules/ada/editor/parser/resources/Ada95ASTParser.cup	Sun Aug 22 23:37:11 2010 +0200
     1.3 @@ -22,7 +22,7 @@
     1.4   * "Portions Copyrighted [year] [name of copyright owner]"
     1.5   *
     1.6   * If you wish your version of this file to be governed by only the CDDL
     1.7 - * or only the GPL Version 2, indicate your decision by binary_adding_operator
     1.8 + * or only the GPL Version 2, indicate your decision by adding
     1.9   * "[Contributor] elects to include this software in this distribution
    1.10   * under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.11   * single choice of license, a recipient has the option to distribute
    1.12 @@ -63,21 +63,19 @@
    1.13          return this.errorHandler;
    1.14      }
    1.15  
    1.16 -/*
    1.17 -    public Dispatch createDispatch(VariableBase dispatcher, VariableBase property) {
    1.18 +
    1.19 +    public Dispatch createDispatch(NameBase dispatcher, NameBase property) {
    1.20          Dispatch dispatch = null;
    1.21  	if (property instanceof Variable) {
    1.22  	   dispatch = new FieldAccess(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (Variable)property);
    1.23 -	} else if (property instanceof FunctionInvocation) {
    1.24 -	   dispatch = new MethodInvocation(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (FunctionInvocation)property);
    1.25 -	} else if (property instanceof ProcedureInvocation) {
    1.26 -	   dispatch = new MethodInvocation(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (ProcedureInvocation)property);
    1.27 +	} else if (property instanceof TypeName) {
    1.28 +	   dispatch = new TypeAccess(dispatcher.getStartOffset(), property.getEndOffset(), dispatcher, (TypeName)property);
    1.29  	} else {
    1.30  	   throw new IllegalArgumentException();
    1.31  	}
    1.32          return dispatch;
    1.33      }
    1.34 -*/
    1.35 +
    1.36  
    1.37      public List setModifier(List items, int modifier) {
    1.38          List list = new LinkedList();
    1.39 @@ -358,11 +356,11 @@
    1.40  non terminal List                    number_declaration;
    1.41  
    1.42  // 4.1 Names
    1.43 -non terminal String                  name;
    1.44 -non terminal String                  simple_name;
    1.45 +non terminal Identifier              name;
    1.46 +non terminal Identifier              simple_name;
    1.47  
    1.48  // 4.1.3 Selected Components
    1.49 -non terminal String                  selected_component;
    1.50 +non terminal Identifier              selected_component;
    1.51  
    1.52  // 4.4 Expressions
    1.53  non terminal Expression              expression;
    1.54 @@ -373,11 +371,11 @@
    1.55  non terminal Expression              primary;
    1.56  
    1.57  // 4.5 Operators and Expression Evaluation
    1.58 -non terminal String                  logical_operator;
    1.59 -non terminal String                  relational_operator;
    1.60 -non terminal UnaryOperation.Operator binary_adding_operator;
    1.61 -non terminal UnaryOperation.Operator unary_adding_operator;
    1.62 -non terminal String                  multiplying_operator;
    1.63 +non terminal InfixExpression.OperatorType logical_operator;
    1.64 +non terminal InfixExpression.OperatorType relational_operator;
    1.65 +non terminal InfixExpression.OperatorType binary_adding_operator;
    1.66 +non terminal UnaryOperation.Operator      unary_adding_operator;
    1.67 +non terminal InfixExpression.OperatorType multiplying_operator;
    1.68  
    1.69  // 4.7 Qualified Expressions
    1.70  non terminal Expression              qualified_expression;
    1.71 @@ -414,7 +412,7 @@
    1.72  
    1.73  // 5.7 Exit Statements
    1.74  non terminal Statement               exit_statement;
    1.75 -non terminal String                  name_opt;
    1.76 +non terminal Expression              name_opt;
    1.77  
    1.78  // 5.8 Goto Statements
    1.79  non terminal Statement               goto_statement;
    1.80 @@ -428,8 +426,8 @@
    1.81  non terminal List                    formal_part;
    1.82  non terminal List                    param;
    1.83  non terminal FormalParameter.Mode    mode;
    1.84 -non terminal String                  designator;
    1.85 -non terminal String                  operator_symbol;
    1.86 +non terminal Identifier              designator;
    1.87 +non terminal Identifier              operator_symbol;
    1.88  
    1.89  // 6.5 Return Statements
    1.90  non terminal Statement               return_statement;
    1.91 @@ -491,30 +489,33 @@
    1.92  
    1.93  
    1.94  // TBD sections
    1.95 -non terminal String                  compound_name;
    1.96 -non terminal String                  compound_name_opt;
    1.97 -non terminal TypeName                object_subtype_def;
    1.98 -non terminal Expression              init_opt;
    1.99 -non terminal Statement               type_decl;
   1.100 -non terminal Expression              type_completion;
   1.101 -non terminal String                  subtype_mark;
   1.102 -non terminal List                    handled_stmt_s;
   1.103 -non terminal Statement               statement;
   1.104 -non terminal Statement               subunit;
   1.105 -non terminal String                  id_opt;
   1.106 -non terminal Statement               unlabeled;
   1.107 -non terminal Expression              literal;
   1.108 -non terminal Expression              parenthesized_primary;
   1.109 -non terminal Expression              when_opt;
   1.110 -non terminal Statement               procedure_call_statement;
   1.111 -non terminal String                  used_char;
   1.112 -non terminal Expression              choice_s;
   1.113 -non terminal String                  label_opt;
   1.114 -non terminal String                  attribute;
   1.115 -non terminal String                  indexed_comp; // TODO: must be change it
   1.116 -non terminal Expression              value_s;
   1.117 -non terminal Expression              discrete_range;
   1.118 -non terminal Expression              range;
   1.119 +non terminal Identifier                   compound_name;
   1.120 +non terminal Identifier                   compound_name_opt;
   1.121 +non terminal TypeName                     object_subtype_def;
   1.122 +non terminal Expression                   init_opt;
   1.123 +non terminal Statement                    type_decl;
   1.124 +non terminal Expression                   type_completion;
   1.125 +non terminal NameBase                     subtype_mark;
   1.126 +non terminal List                         handled_stmt_s;
   1.127 +non terminal Statement                    statement;
   1.128 +non terminal Statement                    subunit;
   1.129 +non terminal Identifier                   id_opt;
   1.130 +non terminal Statement                    unlabeled;
   1.131 +non terminal Expression                   literal;
   1.132 +non terminal Expression                   parenthesized_primary;
   1.133 +non terminal Expression                   when_opt;
   1.134 +non terminal Statement                    procedure_call_statement;
   1.135 +non terminal String                       used_char;
   1.136 +non terminal Expression                   choice_s;
   1.137 +non terminal Identifier                   label_opt;
   1.138 +non terminal Identifier                   attribute;
   1.139 +non terminal Identifier                   indexed_component; // TODO: must be change it
   1.140 +non terminal Expression                   value_s;
   1.141 +non terminal Expression                   discrete_range;
   1.142 +non terminal Expression                   range;
   1.143 +non terminal InfixExpression.OperatorType short_circuit;
   1.144 +non terminal InfixExpression.OperatorType membership;
   1.145 +non terminal String                       attribute_id;
   1.146  
   1.147  // TBD RM sections and types
   1.148  non terminal     pragma;
   1.149 @@ -567,13 +568,10 @@
   1.150  non terminal     prot_opt;
   1.151  non terminal     rep_spec;
   1.152  non terminal     declarative_item_or_body;
   1.153 -non terminal     attribute_id;
   1.154  non terminal     value;
   1.155  non terminal     comp_assoc;
   1.156  non terminal     aggregate;
   1.157  non terminal     value_s_2;
   1.158 -non terminal     short_circuit;
   1.159 -non terminal     membership;
   1.160  non terminal     allocator;
   1.161  non terminal     label;
   1.162  non terminal     requeue_stmt;
   1.163 @@ -635,15 +633,21 @@
   1.164   * JavaCup precedence    *
   1.165   *************************/
   1.166  
   1.167 -//precedence left OR;
   1.168 -//precedence left XOR;
   1.169 -//precedence left AND;
   1.170 +// TODO: must be complete
   1.171 +precedence left OR;
   1.172 +precedence left XOR;
   1.173 +precedence left AND;
   1.174  
   1.175 -//precedence left SEMICOLON;
   1.176 +precedence left SEMICOLON;
   1.177  
   1.178 -//precedence left ELSIF;
   1.179 -//precedence left ELSE;
   1.180 -//precedence left END IF;
   1.181 +precedence left ELSIF;
   1.182 +precedence left ELSE;
   1.183 +precedence left END;
   1.184 +
   1.185 +precedence right NOT;
   1.186 +
   1.187 +precedence nonassoc ASSIGNMENT;
   1.188 +
   1.189  
   1.190  ///////////////////////////////////////////////////////////////////////////////
   1.191  // start with root symbol 
   1.192 @@ -862,15 +866,13 @@
   1.193  
   1.194  subtype_indication ::= 
   1.195  name:name constraint
   1.196 -{:    
   1.197 -    Identifier identifier = new Identifier(nameleft, nameright, name);
   1.198 -    TypeName type = new TypeName (nameleft, nameright, identifier);
   1.199 +{:
   1.200 +    TypeName type = new TypeName (nameleft, nameright, name);
   1.201      RESULT = type;
   1.202  :}
   1.203  | name:name
   1.204  {:    
   1.205 -    Identifier identifier = new Identifier(nameleft, nameright, name);
   1.206 -    TypeName type = new TypeName (nameleft, nameright, identifier);
   1.207 +    TypeName type = new TypeName (nameleft, nameright, name);
   1.208      RESULT = type;
   1.209  :}
   1.210  ;
   1.211 @@ -893,14 +895,20 @@
   1.212  	;
   1.213  
   1.214  range ::=
   1.215 -simple_expression:simple_expr DOT_DOT simple_expression
   1.216 +simple_expression:simple_expression1 DOT_DOT simple_expression:simple_expression2
   1.217  {:
   1.218 -    RESULT = simple_expr;
   1.219 +    Range range = new Range (simple_expression1left, simple_expression2right, simple_expression1, simple_expression2);
   1.220 +    RESULT = range;
   1.221  :}
   1.222 -| name TICK RANGE
   1.223 -| name:name TICK RANGE LPAREN expression:expr RPAREN
   1.224 +| name:name TICK RANGE:end
   1.225  {:
   1.226 -    RESULT = expr;
   1.227 +    Range range = new Range (nameleft, endright, name, name);
   1.228 +    RESULT = range;
   1.229 +:}
   1.230 +| name:name TICK RANGE LPAREN expression:expression RPAREN:end
   1.231 +{:
   1.232 +    Range range = new Range (nameleft, endright, name, expression);
   1.233 +    RESULT = range;
   1.234  :}
   1.235  ;
   1.236  
   1.237 @@ -1209,70 +1217,80 @@
   1.238  :}
   1.239  ;
   1.240  
   1.241 -
   1.242  name ::=
   1.243 -simple_name:name
   1.244 +simple_name:simple_name // direct_name
   1.245  {:
   1.246 -    RESULT = name;
   1.247 +    RESULT = simple_name;
   1.248  :}
   1.249 -| indexed_comp:comp
   1.250 +| operator_symbol:operator_symbol // direct_name
   1.251  {:
   1.252 -    RESULT = comp;
   1.253 +    RESULT = operator_symbol;
   1.254  :}
   1.255 -| selected_component:comp
   1.256 +| indexed_component:indexed_component
   1.257  {:
   1.258 -    RESULT = comp;
   1.259 +    RESULT = indexed_component;
   1.260  :}
   1.261 -| attribute:attr
   1.262 +| selected_component:selected_component
   1.263  {:
   1.264 -    RESULT = attr;
   1.265 +    RESULT = selected_component;
   1.266  :}
   1.267 -| operator_symbol:op
   1.268 +| attribute:attribute
   1.269  {:
   1.270 -    RESULT = op;
   1.271 +    RESULT = attribute;
   1.272  :}
   1.273  ;
   1.274  
   1.275  subtype_mark ::=
   1.276  simple_name:name
   1.277  {:
   1.278 +    TypeName typeName = new TypeName (nameleft, nameright, name);
   1.279 +    RESULT = typeName;
   1.280 +:}
   1.281 +| subtype_mark:name TICK attribute_id:id
   1.282 +{:
   1.283 +    ((TypeName)name).setAttributeId(id);
   1.284      RESULT = name;
   1.285  :}
   1.286 -| subtype_mark:name TICK attribute_id
   1.287 +| subtype_mark:subtype_mark DOT simple_name:simple_name
   1.288  {:
   1.289 -    // TODO: manage the attribute
   1.290 -    RESULT = name;
   1.291 -:}
   1.292 -| subtype_mark:name DOT simple_name:simpleName
   1.293 -{:
   1.294 -    RESULT = name + "." + simpleName;
   1.295 +    Dispatch dispatch;
   1.296 +    TypeName typeName = new TypeName (simple_nameleft, simple_nameright, simple_name);
   1.297 +    if (subtype_mark instanceof TypeName) {
   1.298 +        PackageName packageName = new PackageName (subtype_markleft, subtype_markright, ((TypeName)subtype_mark).getTypeName());
   1.299 +        dispatch = parser.createDispatch(packageName, typeName);
   1.300 +    } else {
   1.301 +        dispatch = parser.createDispatch(subtype_mark, typeName);
   1.302 +    }
   1.303 +
   1.304 +    RESULT = dispatch;
   1.305  :}
   1.306  ;
   1.307  
   1.308  simple_name ::=
   1.309 -IDENTIFIER:identifier
   1.310 +IDENTIFIER:id
   1.311  {:
   1.312 +    Identifier identifier = new Identifier (idleft, idright, id);
   1.313      RESULT = identifier;
   1.314  :}
   1.315  ;
   1.316  
   1.317 +// TODO: must be create a list of identifiers
   1.318  compound_name ::=
   1.319 -simple_name:simpleName
   1.320 +simple_name:simple_name
   1.321  {:
   1.322 -    RESULT = simpleName;
   1.323 +    RESULT = simple_name;
   1.324  :}
   1.325 -| compound_name:compoundName DOT simple_name:simpleName
   1.326 +| compound_name:compound_name DOT simple_name:simple_name
   1.327  {:
   1.328 -    RESULT = compoundName + "." + simpleName;
   1.329 +    RESULT = simple_name;
   1.330  :}
   1.331  ;
   1.332  
   1.333  library_unit_name_list ::=
   1.334 -compound_name:compoundName
   1.335 +compound_name:compound_name
   1.336  {:
   1.337      List nameList = new LinkedList();
   1.338 -    Identifier id = new Identifier(compoundNameleft, compoundNameright, (String)compoundName);
   1.339 -    PackageName packageName = new PackageName(compoundNameleft, compoundNameright, id);
   1.340 +    PackageName packageName = new PackageName(compound_nameleft, compound_nameright, compound_name);
   1.341      nameList.add(packageName);
   1.342      RESULT = nameList;
   1.343  :}
   1.344 @@ -1290,14 +1308,9 @@
   1.345  :}
   1.346  ;
   1.347  
   1.348 -indexed_comp ::=
   1.349 +indexed_component ::=
   1.350  name:name LPAREN value_s:index RPAREN:end
   1.351  {:
   1.352 -    System.out.println ("indexed_comp ::= name => " + name);
   1.353 -    Identifier identifier = new Identifier(nameleft, nameright, name);
   1.354 -    //Variable variable = new Variable (nameleft, nameright, name);
   1.355 -	Variable indexedVar = new ArrayAccess(nameleft, endright, identifier, index, ArrayAccess.Type.VARIABLE_ARRAY);
   1.356 -    //RESULT = indexedVar;
   1.357      RESULT = name;
   1.358  :}
   1.359  ;
   1.360 @@ -1320,21 +1333,25 @@
   1.361  // 4.1.3 Selected Components
   1.362  //
   1.363  selected_component ::=
   1.364 -name:name DOT simple_name:simpleName
   1.365 +name:name DOT simple_name:simple_name
   1.366  {:
   1.367 -    RESULT = name + "." + simpleName;
   1.368 +    Identifier identifier = new Identifier (nameleft, simple_nameright, name.getName() + "." + simple_name.getName());
   1.369 +    RESULT = identifier;
   1.370  :}
   1.371 -| name:name DOT used_char:usedChar
   1.372 +| name:name DOT used_char:used_char
   1.373  {:
   1.374 -    RESULT = name + "." + usedChar;
   1.375 +    Identifier identifier = new Identifier (nameleft, used_charright, name.getName() + "." + used_char);
   1.376 +    RESULT = identifier;
   1.377  :}
   1.378  | name:name DOT operator_symbol:operator
   1.379  {:
   1.380 -    RESULT = name + "." + operator;
   1.381 +    Identifier identifier = new Identifier (nameleft, operatorright, name.getName() + "." + operator.getName());
   1.382 +    RESULT = identifier;
   1.383  :}
   1.384  | name:name DOT ALL:all
   1.385  {:
   1.386 -    RESULT = name + "." + all;
   1.387 +    Identifier identifier = new Identifier (nameleft, allright, name.getName() + "." + "all");
   1.388 +    RESULT = identifier;
   1.389  :}
   1.390  ;
   1.391  
   1.392 @@ -1345,29 +1362,34 @@
   1.393  :}
   1.394  ;
   1.395  
   1.396 -attribute_id ::= IDENTIFIER
   1.397 -	| DIGITS
   1.398 -	| DELTA
   1.399 -	| ACCESS
   1.400 -	;
   1.401 +attribute_id ::=
   1.402 +IDENTIFIER
   1.403 +| DIGITS
   1.404 +| DELTA
   1.405 +| ACCESS
   1.406 +;
   1.407  
   1.408  literal ::=
   1.409  DECIMAL_LITERAL:dec
   1.410  {:
   1.411 -	Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
   1.412 -	RESULT = scalar;
   1.413 +    Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
   1.414 +    RESULT = scalar;
   1.415  :}
   1.416  | BASED_LITERAL:dec
   1.417  {:
   1.418 -	Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
   1.419 -	RESULT = scalar;
   1.420 +    Scalar scalar = new Scalar(decleft, decright, dec, Scalar.Type.INT);
   1.421 +    RESULT = scalar;
   1.422  :}
   1.423  | used_char:usedChar
   1.424  {:
   1.425 -	Scalar scalar = new Scalar(usedCharleft, usedCharright, usedChar, Scalar.Type.STRING);
   1.426 -	RESULT = scalar;
   1.427 +    Scalar scalar = new Scalar(usedCharleft, usedCharright, usedChar, Scalar.Type.STRING);
   1.428 +    RESULT = scalar;
   1.429  :}
   1.430 -| NULL
   1.431 +| NULL:token
   1.432 +{:
   1.433 +    Scalar scalar = new Scalar(tokenleft, tokenright, "null", Scalar.Type.SYSTEM);
   1.434 +    RESULT = scalar;
   1.435 +:}
   1.436  ;
   1.437  
   1.438  aggregate ::= LPAREN comp_assoc RPAREN
   1.439 @@ -1390,27 +1412,67 @@
   1.440  //
   1.441  logical_operator ::=
   1.442  AND
   1.443 +{:
   1.444 +    RESULT = InfixExpression.OperatorType.BOOL_AND;
   1.445 +:}
   1.446  | OR
   1.447 +{:
   1.448 +    RESULT = InfixExpression.OperatorType.BOOL_OR;
   1.449 +:}
   1.450  | XOR
   1.451 +{:
   1.452 +    RESULT = InfixExpression.OperatorType.BOOL_XOR;
   1.453 +:}
   1.454  ;
   1.455  
   1.456 -short_circuit ::= AND THEN
   1.457 -	| OR ELSE
   1.458 -	;
   1.459 -
   1.460 +short_circuit ::=
   1.461 +AND THEN
   1.462 +{:
   1.463 +    RESULT = InfixExpression.OperatorType.BOOL_OR;
   1.464 +:}
   1.465 +| OR ELSE
   1.466 +{:
   1.467 +    RESULT = InfixExpression.OperatorType.BOOL_AND;
   1.468 +:}
   1.469 +;
   1.470  
   1.471  relational_operator ::=
   1.472  EQ
   1.473 +{:
   1.474 +    RESULT = InfixExpression.OperatorType.IS_EQUAL;
   1.475 +:}
   1.476  | INEQ
   1.477 +{:
   1.478 +    RESULT = InfixExpression.OperatorType.IS_NOT_EQUAL;
   1.479 +:}
   1.480  | GT
   1.481 +{:
   1.482 +    RESULT = InfixExpression.OperatorType.RGREATER;
   1.483 +:}
   1.484  | LTEQ
   1.485 +{:
   1.486 +    RESULT = InfixExpression.OperatorType.IS_SMALLER_OR_EQUAL;
   1.487 +:}
   1.488  | LT
   1.489 +{:
   1.490 +    RESULT = InfixExpression.OperatorType.LGREATER;
   1.491 +:}
   1.492  | GTEQ
   1.493 +{:
   1.494 +    RESULT = InfixExpression.OperatorType.IS_GREATER_OR_EQUAL;
   1.495 +:}
   1.496  ;
   1.497  
   1.498 -membership ::= IN
   1.499 -	| NOT IN
   1.500 -	;
   1.501 +membership ::=
   1.502 +IN
   1.503 +{:
   1.504 +    RESULT = InfixExpression.OperatorType.IN;
   1.505 +:}
   1.506 +| NOT IN
   1.507 +{:
   1.508 +    RESULT = InfixExpression.OperatorType.NOT_IN;
   1.509 +:}
   1.510 +;
   1.511  
   1.512  unary_adding_operator ::=
   1.513  PLUS
   1.514 @@ -1426,79 +1488,93 @@
   1.515  binary_adding_operator ::= 
   1.516  PLUS
   1.517  {:
   1.518 -    RESULT = UnaryOperation.Operator.PLUS;
   1.519 +    RESULT = InfixExpression.OperatorType.PLUS;
   1.520  :}
   1.521  | MINUS
   1.522  {:
   1.523 -    RESULT = UnaryOperation.Operator.MINUS;
   1.524 +    RESULT = InfixExpression.OperatorType.MINUS;
   1.525  :}
   1.526  | AMP
   1.527  {:
   1.528 -    RESULT = UnaryOperation.Operator.AMP;
   1.529 +    RESULT = InfixExpression.OperatorType.STRING_AND;
   1.530  :}
   1.531  ;
   1.532  
   1.533  multiplying_operator ::=
   1.534  STAR
   1.535 +{:
   1.536 +    RESULT = InfixExpression.OperatorType.MUL;
   1.537 +:}
   1.538  | SLASH
   1.539 +{:
   1.540 +    RESULT = InfixExpression.OperatorType.DIV;
   1.541 +:}
   1.542  | MOD
   1.543 +{:
   1.544 +    RESULT = InfixExpression.OperatorType.MOD;
   1.545 +:}
   1.546  | REM
   1.547 +{:
   1.548 +    RESULT = InfixExpression.OperatorType.REM;
   1.549 +:}
   1.550  ;
   1.551  
   1.552  ///////////////////////////////////////////////////////////////////////////////
   1.553  // 4.4 Expressions
   1.554  //
   1.555  expression ::=
   1.556 -relation:rel
   1.557 +relation:relation
   1.558  {:
   1.559 -    System.out.println ("expression ::= relation => " + rel);
   1.560 -	RESULT = rel;
   1.561 +    RESULT = relation;
   1.562  :}
   1.563 -| expression:expr logical_operator relation:rel
   1.564 +| expression:expression logical_operator:logical_operator relation:relation
   1.565  {:
   1.566 -    System.out.println ("expression ::= expression => " + expr);
   1.567 -    System.out.println ("expression ::= relation => " + rel);
   1.568 -	RESULT = expr;
   1.569 +    InfixExpression infixExpression = new InfixExpression(expressionleft, relationright, expression, logical_operator, relation);
   1.570 +    RESULT = infixExpression;
   1.571  :}
   1.572 -| expression:expr short_circuit relation:rel
   1.573 +| expression:expression short_circuit:short_circuit relation:relation
   1.574  {:
   1.575 -    System.out.println ("expression ::= expression => " + expr);
   1.576 -    System.out.println ("expression ::= relation => " + rel);
   1.577 -	RESULT = expr;
   1.578 +    InfixExpression infixExpression = new InfixExpression(expressionleft, relationright, expression, short_circuit, relation);
   1.579 +    RESULT = infixExpression;
   1.580  :}
   1.581  ;
   1.582  
   1.583  relation ::=
   1.584 -simple_expression:simple_expr
   1.585 +simple_expression:simple_expression
   1.586  {:
   1.587 -    RESULT = simple_expr;
   1.588 +    RESULT = simple_expression;
   1.589  :}
   1.590 -| simple_expression:simple_expr relational_operator simple_expression
   1.591 +| simple_expression:simple_expression1 relational_operator:relational_operator simple_expression:simple_expression2
   1.592  {:
   1.593 -    RESULT = simple_expr;
   1.594 +    InfixExpression infixExpression = new InfixExpression(simple_expression1left, simple_expression2right, simple_expression1, relational_operator, simple_expression2);
   1.595 +    RESULT = infixExpression;
   1.596  :}
   1.597 -| simple_expression:simple_expr membership range
   1.598 +| simple_expression:simple_expression membership:membership range:range
   1.599  {:
   1.600 -    RESULT = simple_expr;
   1.601 +    InfixExpression infixExpression = new InfixExpression(simple_expressionleft, rangeright, simple_expression, membership, range);
   1.602 +    RESULT = infixExpression;
   1.603  :}
   1.604 -| simple_expression:simple_expr membership name
   1.605 +| simple_expression:simple_expression membership:membership name:name
   1.606  {:
   1.607 -    RESULT = simple_expr;
   1.608 +    InfixExpression infixExpression = new InfixExpression(simple_expressionleft, nameright, simple_expression, membership, name);
   1.609 +    RESULT = infixExpression;
   1.610  :}
   1.611  ;
   1.612  
   1.613  simple_expression ::=
   1.614 -unary_adding_operator:op term:term
   1.615 +unary_adding_operator:unary_adding_operator term:term
   1.616  {:
   1.617 -	RESULT = new UnaryOperation(opleft, termright, term, op);
   1.618 +    UnaryOperation unaryOperation = new UnaryOperation(unary_adding_operatorleft, termright, term, unary_adding_operator);
   1.619 +    RESULT = unaryOperation;
   1.620  :}
   1.621  | term:term
   1.622  {:
   1.623      RESULT = term;
   1.624  :}
   1.625 -| simple_expression:expr binary_adding_operator:op term:term
   1.626 +| simple_expression:simple_expression binary_adding_operator:binary_adding_operator term:term
   1.627  {:
   1.628 -	RESULT = new UnaryOperation(exprleft, termright, term, op);
   1.629 +    InfixExpression infixExpression = new InfixExpression(simple_expressionleft, termright, simple_expression, binary_adding_operator, term);
   1.630 +    RESULT = infixExpression;
   1.631  :}
   1.632  ;
   1.633  
   1.634 @@ -1507,9 +1583,10 @@
   1.635  {:
   1.636      RESULT = factor;
   1.637  :}
   1.638 -| term multiplying_operator factor:factor
   1.639 +| term:term multiplying_operator:multiplying_operator factor:factor
   1.640  {:
   1.641 -    RESULT = factor;
   1.642 +    InfixExpression infixExpression = new InfixExpression(termleft, factorright, term, multiplying_operator, factor);
   1.643 +    RESULT = infixExpression;
   1.644  :}
   1.645  ;
   1.646  
   1.647 @@ -1518,58 +1595,57 @@
   1.648  {:
   1.649      RESULT = primary;
   1.650  :}
   1.651 -| NOT primary:primary
   1.652 +| NOT:token primary:primary
   1.653  {:
   1.654 -    RESULT = primary;
   1.655 +    UnaryOperation unaryOperation = new UnaryOperation(tokenleft, primaryright, primary, UnaryOperation.Operator.NOT);
   1.656 +    RESULT = unaryOperation;
   1.657  :}
   1.658 -| ABS primary:primary
   1.659 +| ABS:token primary:primary
   1.660  {:
   1.661 -    RESULT = primary;
   1.662 +    UnaryOperation unaryOperation = new UnaryOperation(tokenleft, primaryright, primary, UnaryOperation.Operator.ABS);
   1.663 +    RESULT = unaryOperation;
   1.664  :}
   1.665 -| primary EXPON primary:primary
   1.666 +| primary:primary1 EXPON primary:primary2
   1.667  {:
   1.668 -    RESULT = primary;
   1.669 +    InfixExpression infixExpression = new InfixExpression(primary1left, primary2right, primary1, InfixExpression.OperatorType.EXPON, primary2);
   1.670 +    RESULT = infixExpression;
   1.671  :}
   1.672  ;
   1.673  
   1.674  primary ::=
   1.675  literal:literal
   1.676  {:
   1.677 -    System.out.println ("primary ::= literal => " + literal);
   1.678      RESULT = literal;
   1.679  :}
   1.680  | name:name
   1.681  {:
   1.682 -    System.out.println ("primary ::= name => " + name);
   1.683 -    Scalar scalar = new Scalar(nameleft, nameright, name, Scalar.Type.STRING);
   1.684 -    RESULT = scalar;
   1.685 +// TODO: must be modified for manage all primery types
   1.686 +    Variable variable = new Variable (nameleft, nameright, name);
   1.687 +    RESULT = variable;
   1.688  :}
   1.689  | allocator
   1.690 -| qualified_expression:expr
   1.691 +| qualified_expression:qualified_expression
   1.692  {:
   1.693 -    System.out.println ("primary ::= qualified_expression => " + expr);
   1.694 -    RESULT = expr;
   1.695 +    RESULT = qualified_expression;
   1.696  :}
   1.697 -| parenthesized_primary:expr
   1.698 +| parenthesized_primary:parenthesized_primary
   1.699  {:
   1.700 -    System.out.println ("primary ::= parenthesized_primary => " + expr);
   1.701 -    RESULT = expr;
   1.702 +    RESULT = parenthesized_primary;
   1.703  :}
   1.704  ;
   1.705  
   1.706  parenthesized_primary ::=
   1.707  aggregate
   1.708 -| LPAREN expression:expr RPAREN
   1.709 +| LPAREN expression:expression RPAREN
   1.710  {:
   1.711 -    RESULT = expr;
   1.712 +    RESULT = expression;
   1.713  :}
   1.714  ;
   1.715  
   1.716  qualified_expression ::=
   1.717  name:name TICK parenthesized_primary:expr
   1.718  {:
   1.719 -    Identifier subtypeMark = new Identifier (nameleft, nameright, name);
   1.720 -    RESULT = new QualifiedExpression (nameleft, exprright, subtypeMark, expr);
   1.721 +    RESULT = new QualifiedExpression (nameleft, exprright, name, expr);
   1.722  :}
   1.723  ;
   1.724  
   1.725 @@ -1701,13 +1777,10 @@
   1.726  // 5.2 Assignment Statements
   1.727  //
   1.728  assignment_statement ::=
   1.729 -name:var ASSIGNMENT expression:expr SEMICOLON
   1.730 +name:name ASSIGNMENT expression:expression SEMICOLON
   1.731  {:
   1.732 -    System.out.println ("assignment_statement ::= var => " + var);
   1.733 -    System.out.println ("assignment_statement ::= expr => " + expr);
   1.734 -    Identifier id = new Identifier(varleft, varright, var);
   1.735 -    Variable variable = new Variable (varleft, varright, (Identifier)id);
   1.736 -    Assignment assignment = new Assignment(varleft, exprright, variable, expr);
   1.737 +    Variable variable = new Variable (nameleft, nameright, name);
   1.738 +    Assignment assignment = new Assignment(nameleft, expressionright, variable, expression);
   1.739      RESULT = assignment;
   1.740  :}
   1.741  ;
   1.742 @@ -1722,19 +1795,19 @@
   1.743      Expression firstCondition = null;
   1.744      Statement trueStatement = null;
   1.745      Statement falseStatement = iffalse;
   1.746 -		
   1.747 +
   1.748      for (int i=1 ; i < condList[0].size() ; i++) {
   1.749          innerCondition = (Expression)condList[0].get(i);
   1.750          trueStatement = (Statement)condList[1].get(i);
   1.751          int start = ((Integer)condList[2].get(i)).intValue();
   1.752          falseStatement = new IfStatement(start, endright, innerCondition, trueStatement, falseStatement);
   1.753      }
   1.754 -    
   1.755 +
   1.756      firstCondition = (Expression)condList[0].get(0);
   1.757      trueStatement = (Statement)condList[1].get(0);
   1.758      int start = ((Integer)condList[2].get(0)).intValue();
   1.759      IfStatement ifStatement = new IfStatement(tokenleft, endright, firstCondition, trueStatement, falseStatement);		
   1.760 -	
   1.761 +
   1.762      RESULT = ifStatement;
   1.763  :}
   1.764  ;
   1.765 @@ -1767,9 +1840,9 @@
   1.766  ;
   1.767  
   1.768  condition ::=
   1.769 -expression:expr
   1.770 +expression:expression
   1.771  {:
   1.772 -    RESULT = expr;
   1.773 +    RESULT = expression;
   1.774  :}
   1.775  ;
   1.776  
   1.777 @@ -1824,8 +1897,7 @@
   1.778  label_opt:label iteration:iteration basic_loop:statement id_opt SEMICOLON:end
   1.779  {:
   1.780      int start = (label == null) ? iterationleft : labelleft;
   1.781 -    Identifier identifier = new Identifier(labelleft, labelright, label);
   1.782 -    LoopStatement loopStatement = new LoopStatement(start, endright, identifier, iteration, statement);
   1.783 +    LoopStatement loopStatement = new LoopStatement(start, endright, label, iteration, statement);
   1.784      RESULT = loopStatement;
   1.785  :}
   1.786  ;
   1.787 @@ -1837,7 +1909,8 @@
   1.788  :}
   1.789  | IDENTIFIER:id COLON
   1.790  {:
   1.791 -    RESULT = id;
   1.792 +    Identifier identifier = new Identifier (idleft, idright, id);
   1.793 +    RESULT = identifier;
   1.794  :}
   1.795  ;
   1.796  
   1.797 @@ -1880,9 +1953,9 @@
   1.798  {:
   1.799      RESULT = null;
   1.800  :}
   1.801 -| designator:name
   1.802 +| designator:designator
   1.803  {:
   1.804 -    RESULT = name;
   1.805 +    RESULT = designator;
   1.806  :}
   1.807  ;
   1.808  
   1.809 @@ -1893,8 +1966,7 @@
   1.810  label_opt:label block_declarative:declarations block_body:body END id_opt SEMICOLON:end
   1.811  {:
   1.812      int start = (label == null) ? declarationsleft : labelleft;
   1.813 -    Identifier identifier = new Identifier(labelleft, labelright, label);
   1.814 -    BlockStatement blockStatement = new BlockStatement (start, endleft, identifier, declarations, body);
   1.815 +    BlockStatement blockStatement = new BlockStatement (start, endleft, label, declarations, body);
   1.816      RESULT = blockStatement;
   1.817  :}
   1.818  ;
   1.819 @@ -2002,23 +2074,19 @@
   1.820  ;
   1.821  
   1.822  subprogram_specification ::=
   1.823 -PROCEDURE:procedure compound_name:procedureName formal_part_opt:formalPart
   1.824 +PROCEDURE:procedure compound_name:compound_name formal_part_opt:formal_part
   1.825  {:
   1.826 -    Identifier procedureId = new Identifier(procedureNameleft, procedureNameright, procedureName);
   1.827 -    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(procedureleft, formalPartright, procedureId, formalPart);
   1.828 +    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(procedureleft, formal_partright, compound_name, formal_part);
   1.829      RESULT = subprogramSpecification;
   1.830  :}
   1.831 -| FUNCTION:function designator:functionName formal_part_opt:formalPart RETURN name:subtypeMark
   1.832 +| FUNCTION:function designator:designator formal_part_opt:formal_part RETURN name:subtype_mark
   1.833  {:
   1.834 -    Identifier functionId = new Identifier(functionNameleft, functionNameright, functionName);
   1.835 -    Identifier subtypeReturn = new Identifier(subtypeMarkleft, subtypeMarkright, subtypeMark);
   1.836 -    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, subtypeMarkright, functionId, formalPart, subtypeReturn);
   1.837 +    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, subtype_markright, designator, formal_part, subtype_mark);
   1.838      RESULT = subprogramSpecification;
   1.839  :}
   1.840 -| FUNCTION:function designator:functionName  /* for generic inst and generic rename */
   1.841 +| FUNCTION:function designator:designator  /* for generic inst and generic rename */
   1.842  {:
   1.843 -    Identifier functionId = new Identifier(functionNameleft, functionNameright, functionName);
   1.844 -    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, functionNameright, functionId);
   1.845 +    SubprogramSpecification subprogramSpecification = new SubprogramSpecification(functionleft, designatorright, designator);
   1.846      RESULT = subprogramSpecification;
   1.847  :}
   1.848  ;
   1.849 @@ -2071,13 +2139,11 @@
   1.850  defining_identifier_list:identifierList COLON mode:mode subtype_mark:subtype init_opt:init
   1.851  {:
   1.852      List list = new LinkedList();
   1.853 -    Identifier subtypeId = new Identifier(subtypeleft, subtyperight, subtype);
   1.854 -    TypeName typeName = new TypeName(subtypeleft, subtyperight, subtypeId);
   1.855      for (Object item : identifierList) {
   1.856          Identifier identifier = (Identifier)item;
   1.857          Variable variable = new Variable (identifier.getStartOffset(), identifier.getEndOffset(), identifier);
   1.858  	    int end = init == null ? subtyperight : initright;
   1.859 -        FormalParameter parameter = new FormalParameter(identifierListleft, end, variable, mode, typeName, init);
   1.860 +        FormalParameter parameter = new FormalParameter(identifierListleft, end, variable, mode, subtype, init);
   1.861      	list.add(parameter);
   1.862      }
   1.863      RESULT = list;
   1.864 @@ -2116,23 +2182,23 @@
   1.865  
   1.866  // TODO: manage the overload operators ex: "+" "and" ecc.
   1.867  operator_symbol ::=
   1.868 -STRING_LITERAL:stringLiteral
   1.869 +STRING_LITERAL:string_literal
   1.870  {:
   1.871 -    RESULT = stringLiteral;
   1.872 +    Identifier identifier = new Identifier (string_literalleft, string_literalright, string_literal);
   1.873 +    RESULT = identifier;
   1.874  :}
   1.875  ;
   1.876  
   1.877  subprogram_body ::=
   1.878  subprogram_specification:subprog IS
   1.879 -declarative_part:declarativePart block_body:body END id_opt:idOpt SEMICOLON:end
   1.880 +declarative_part:declarativePart block_body:body END id_opt:id_opt SEMICOLON:end
   1.881  {:
   1.882 -    if (idOpt != null && !idOpt.equalsIgnoreCase (subprog.getSubprogramName().getName())) {
   1.883 +    if (id_opt != null && !id_opt.getName().equalsIgnoreCase (subprog.getSubprogramName().getName())) {
   1.884          this.parser.message_error("mispelling of " + subprog.getSubprogramName().getName());
   1.885      } else {
   1.886          Block declarations = new Block(subprogright, bodyleft, declarativePart);
   1.887          body.setEndOffset(endright);
   1.888 -        Identifier nameEnd = new Identifier(idOptleft, idOptright, idOpt);
   1.889 -        SubprogramBody subprogramBody = new SubprogramBody(subprogleft, endright, subprog, declarations, body, nameEnd);
   1.890 +        SubprogramBody subprogramBody = new SubprogramBody(subprogleft, endright, subprog, declarations, body, id_opt);
   1.891          MethodDeclaration methodDeclaration = new MethodDeclaration(subprogleft, endright, 0/*modifier*/, subprogramBody);
   1.892          RESULT = methodDeclaration;
   1.893      }
   1.894 @@ -2159,20 +2225,18 @@
   1.895  ;
   1.896  
   1.897  package_specification ::= 
   1.898 -PACKAGE:declarationStart compound_name:packageName IS:blockStart
   1.899 +PACKAGE:declarationStart compound_name:package_name IS:blockStart
   1.900    declarative_items_opt:declarativeItems private_part:privateDeclarativeItems
   1.901 -END:declarationEnd compound_name_opt:packageNameEnd
   1.902 +END:declarationEnd compound_name_opt:package_name_end
   1.903  {:
   1.904 -    if (packageNameEnd != null && !packageNameEnd.equalsIgnoreCase (packageName)) {
   1.905 -        this.parser.message_error("mispelling of " + packageName);
   1.906 +    if (package_name_end != null && !package_name_end.getName().equalsIgnoreCase (package_name.getName())) {
   1.907 +        this.parser.message_error("mispelling of " + package_name);
   1.908      }
   1.909      else {
   1.910 -        Identifier packageId = new Identifier(packageNameleft, packageNameright, packageName);
   1.911 -        Identifier packageIdEnd = new Identifier(packageNameEndleft, packageNameEndright, packageNameEnd);
   1.912          declarativeItems.addAll (privateDeclarativeItems);
   1.913          // Add private part on block statements
   1.914          Block block = new Block(blockStartleft, declarationEndright, declarativeItems);
   1.915 -        PackageSpecification packageSpecification = new PackageSpecification(declarationStartleft, declarationEndright, packageId, packageIdEnd, block);
   1.916 +        PackageSpecification packageSpecification = new PackageSpecification(declarationStartleft, declarationEndright, package_name, package_name_end, block);
   1.917          RESULT = packageSpecification;
   1.918      }
   1.919  :}
   1.920 @@ -2190,9 +2254,9 @@
   1.921  
   1.922  compound_name_opt ::=
   1.923  // empty
   1.924 -| compound_name:compoundName
   1.925 +| compound_name:compound_name
   1.926  {:
   1.927 -    RESULT = compoundName;
   1.928 +    RESULT = compound_name;
   1.929  :}
   1.930  ;
   1.931  
   1.932 @@ -2200,20 +2264,18 @@
   1.933  // 7.2 Package Bodies
   1.934  //
   1.935  package_body ::=
   1.936 -PACKAGE:declarationStart BODY compound_name:packageName IS:blockStart
   1.937 -  declarative_part:declarativePart body_opt END compound_name_opt:packageNameEnd SEMICOLON:declarationEnd
   1.938 +PACKAGE:declarationStart BODY compound_name:package_name IS:blockStart
   1.939 +  declarative_part:declarativePart body_opt END compound_name_opt:package_name_end SEMICOLON:declarationEnd
   1.940  {:
   1.941 -    if (packageNameEnd != null && !packageNameEnd.equalsIgnoreCase (packageName)) {
   1.942 -        this.parser.message_error("mispelling of " + packageName);
   1.943 +    if (package_name_end != null && !package_name_end.getName().equalsIgnoreCase (package_name.getName())) {
   1.944 +        this.parser.message_error("mispelling of " + package_name);
   1.945      }
   1.946      else {
   1.947 -        Identifier packageId = new Identifier(packageNameleft, packageNameright, packageName);
   1.948 -        Identifier packageIdEnd = new Identifier(packageNameEndleft, packageNameEndright, packageNameEnd);
   1.949  
   1.950          List list = this.parser.setModifier (declarativePart, Ada95ASTParser.PRIVATE);
   1.951          Block block = new Block(blockStartleft, declarationEndright, list);
   1.952  
   1.953 -        PackageBody packageBody = new PackageBody(declarationStartleft, declarationEndright, packageId, packageIdEnd, block);
   1.954 +        PackageBody packageBody = new PackageBody(declarationStartleft, declarationEndright, package_name, package_name_end, block);
   1.955          RESULT = packageBody;
   1.956      }
   1.957  :}
   1.958 @@ -2262,15 +2324,13 @@
   1.959  name:name
   1.960  {:
   1.961      List idList = new LinkedList();
   1.962 -    Identifier id = new Identifier(nameleft, nameright, name);
   1.963 -    PackageName packageName = new PackageName(nameleft, nameright, id);
   1.964 +    PackageName packageName = new PackageName(nameleft, nameright, name);
   1.965      idList.add(packageName);
   1.966      RESULT = idList;
   1.967  :}
   1.968  | package_name_list:idList COMMA name:name
   1.969  {:
   1.970 -    Identifier id = new Identifier(nameleft, nameright, name);
   1.971 -    PackageName packageName = new PackageName(nameleft, nameright, id);
   1.972 +    PackageName packageName = new PackageName(nameleft, nameright, name);
   1.973      idList.add(packageName);
   1.974      RESULT = idList;
   1.975  :}
   1.976 @@ -2280,15 +2340,13 @@
   1.977  name:name
   1.978  {:
   1.979      List idList = new LinkedList();
   1.980 -    Identifier id = new Identifier(nameleft, nameright, name);
   1.981 -    TypeName typeName = new TypeName(nameleft, nameright, id);
   1.982 +    TypeName typeName = new TypeName(nameleft, nameright, name);
   1.983      idList.add(typeName);
   1.984      RESULT = idList;
   1.985  :}
   1.986  | subtype_mark_list:idList COMMA name:name
   1.987  {:
   1.988 -    Identifier id = new Identifier(nameleft, nameright, name);
   1.989 -    TypeName typeName = new TypeName(nameleft, nameright, id);
   1.990 +    TypeName typeName = new TypeName(nameleft, nameright, name);
   1.991      idList.add(typeName);
   1.992      RESULT = idList;
   1.993  :}
   1.994 @@ -2310,9 +2368,7 @@
   1.995  rename_unit ::= 
   1.996  PACKAGE:token compound_name:name RENAMES name:renames SEMICOLON:end
   1.997  {:
   1.998 -    Identifier packageNameId = new Identifier(nameleft, nameright, name);
   1.999 -    Identifier packageRenamesId = new Identifier(renamesleft, renamesright, renames);
  1.1000 -    PackageRenames packageRenames = new PackageRenames(tokenleft, endright, packageNameId, packageRenamesId);
  1.1001 +    PackageRenames packageRenames = new PackageRenames(tokenleft, endright, name, renames);
  1.1002      RESULT = packageRenames;
  1.1003  :}
  1.1004  | subprogram_specification RENAMES name SEMICOLON:end
  1.1005 @@ -2499,15 +2555,13 @@
  1.1006  name:name
  1.1007  {:
  1.1008      List idList = new LinkedList();
  1.1009 -    Identifier id = new Identifier(nameleft, nameright, name);
  1.1010 -    TaskName taskName = new TaskName(nameleft, nameright, id);
  1.1011 +    TaskName taskName = new TaskName(nameleft, nameright, name);
  1.1012      idList.add(taskName);
  1.1013      RESULT = idList;
  1.1014  :}
  1.1015  | task_name_list:idList COMMA name:name
  1.1016  {:
  1.1017 -    Identifier id = new Identifier(nameleft, nameright, name);
  1.1018 -    TaskName taskName = new TaskName(nameleft, nameright, id);
  1.1019 +    TaskName taskName = new TaskName(nameleft, nameright, name);
  1.1020      idList.add(taskName);
  1.1021      RESULT = idList;
  1.1022  :}