start of new file
[IRC.git] / Robust / src / Parse / java14.cup
index 7bb3ffefaf2ebc71f1f33d1d61398cb7dc78eeda..85d18b58f97a95cf983e81df9cfcd597e166073f 100644 (file)
@@ -103,6 +103,7 @@ terminal ASSERT; // assert_statement
 terminal ELLIPSIS;
 terminal ENUM;
 
+
 // 19.2) The Syntactic Grammar
 non terminal ParseNode goal;
 // 19.3) Lexical Structure
@@ -114,17 +115,17 @@ non terminal ParseNode reference_type;
 non terminal ParseNode class_or_interface_type;
 non terminal ParseNode class_type;
 //non terminal ParseNode interface_type;
-//non terminal ParseNode array_type;
+non terminal ParseNode array_type;
 // 19.5) Names
 non terminal ParseNode name, simple_name, qualified_name;
 // 19.6) Packages
 non terminal ParseNode compilation_unit;
-//non terminal ParseNode package_declaration_opt, package_declaration;
-//non terminal ParseNode import_declarations_opt, import_declarations;
+non terminal ParseNode package_declaration_opt, package_declaration;
+non terminal ParseNode import_declarations_opt, import_declarations;
 non terminal ParseNode type_declarations_opt, type_declarations;
-//non terminal ParseNode import_declaration;
-//non terminal ParseNode single_type_import_declaration;
-//non terminal ParseNode type_import_on_demand_declaration;
+non terminal ParseNode import_declaration;
+non terminal ParseNode single_type_import_declaration;
+non terminal ParseNode type_import_on_demand_declaration;
 non terminal ParseNode type_declaration;
 // 19.7) Productions used only in the LALR(1) grammar
 non terminal ParseNode modifiers_opt, modifiers, modifier;
@@ -151,7 +152,7 @@ non terminal ParseNode method_body;
 // 19.8.5) Constructor Declarations
 non terminal ParseNode constructor_declaration, constructor_declarator;
 non terminal ParseNode constructor_body;
-//non terminal ParseNode explicit_constructor_invocation;
+non terminal ParseNode explicit_constructor_invocation;
 // 19.9.1) Interface Declarations
 //non terminal ParseNode interface_declaration;
 //non terminal ParseNode extends_interfaces_opt, extends_interfaces;
@@ -195,11 +196,14 @@ non terminal ParseNode return_statement;
 // 19.12) Expressions
 non terminal ParseNode primary, primary_no_new_array;
 non terminal ParseNode class_instance_creation_expression;
+non terminal ParseNode cons_argument_list_opt, cons_argument_list;
 non terminal ParseNode argument_list_opt, argument_list;
-//non terminal ParseNode array_creation_init, array_creation_uninit;
-//non terminal ParseNode dim_exprs, dim_expr, dims_opt, dims;
+//non terminal ParseNode array_creation_init;
+non terminal ParseNode array_creation_uninit;
+non terminal ParseNode dim_exprs, dim_expr;
+non terminal Integer dims_opt, dims;
 non terminal ParseNode field_access, method_invocation;
-//non terminal ParseNode array_access;
+non terminal ParseNode array_access;
 non terminal ParseNode postfix_expression;
 non terminal ParseNode postincrement_expression, postdecrement_expression;
 non terminal ParseNode unary_expression, unary_expression_not_plus_minus;
@@ -215,9 +219,261 @@ non terminal ParseNode assignment;
 non terminal ParseNode assignment_operator;
 non terminal ParseNode expression_opt, expression;
 //non terminal ParseNode constant_expression;
+//failure aware computation keywords
+terminal FLAG;
+terminal OPTIONAL;
+terminal ISAVAILABLE;
+terminal EXTERNAL;
+terminal TAG;
+terminal TASK;
+terminal TASKEXIT;
+non terminal ParseNode flag_declaration;
+non terminal ParseNode task_declaration;
+non terminal ParseNode task_parameter_list;
+non terminal ParseNode task_parameter;
+non terminal ParseNode flag_expression;
+non terminal ParseNode flag_andexpression;
+non terminal ParseNode flag_notexpression;
+non terminal ParseNode task_exitstatement;
+non terminal ParseNode flag_effects_opt;
+non terminal ParseNode flag_effects;
+non terminal ParseNode flag_effect;
+non terminal ParseNode flag_list;
+non terminal ParseNode flag_list_opt;
+non terminal ParseNode flag_change;
+
+non terminal ParseNode cons_checks_opt;
+non terminal ParseNode cons_checks;
+non terminal ParseNode cons_check;
+
+non terminal ParseNode tag_variable_declaration_statement;
+non terminal ParseNode tag_expression_list;
+non terminal ParseNode tag_expression;
+non terminal ParseNode tag_list;
+non terminal ParseNode tag_list_opt;
+non terminal ParseNode tag_change;
+
+//distributed transaction keywords
+terminal ATOMIC;
+terminal GLOBAL;
+non terminal ParseNode atomic_statement;
+
 
 start with goal;
 
+
+// Task declarations
+task_declaration ::= 
+       TASK IDENTIFIER:id LPAREN task_parameter_list:tpl RPAREN 
+       flag_effects_opt:feo
+       method_body:body 
+       {: 
+       ParseNode pn=new ParseNode("task_declaration");
+       pn.addChild("name").addChild(id);
+       pn.addChild(tpl);
+       pn.addChild(feo);
+       pn.addChild("body").addChild(body);     
+       RESULT=pn;
+       :};
+
+task_parameter_list ::=
+               task_parameter:fp {: 
+               ParseNode pn=new ParseNode("task_parameter_list");
+               pn.addChild(fp);
+               RESULT=pn;
+       :}
+       |       task_parameter_list:fpl COMMA task_parameter:fp {: 
+               fpl.addChild(fp);
+               RESULT=fpl;
+       :}
+       ;
+
+task_parameter ::=
+               type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE {:
+               ParseNode pn=new ParseNode("task_parameter");
+               pn.addChild(type);
+               pn.addChild(name);
+               pn.addChild("flag").addChild(exp);
+               RESULT=pn;
+       :} 
+        | type:type variable_declarator_id:name LBRACE flag_expression:exp RBRACE LBRACE tag_expression_list:texp RBRACE {:
+               ParseNode pn=new ParseNode("task_parameter");
+               pn.addChild(type);
+               pn.addChild(name);
+               pn.addChild("flag").addChild(exp);
+               pn.addChild("tag").addChild(texp);
+               RESULT=pn;
+       :}
+        | type:type variable_declarator_id:name LBRACE RBRACE LBRACE tag_expression_list:texp RBRACE {:
+               ParseNode pn=new ParseNode("task_parameter");
+               pn.addChild(type);
+               pn.addChild(name);
+               pn.addChild("tag").addChild(texp);
+               RESULT=pn;
+       :}
+       | OPTIONAL task_parameter:fp {:
+               ParseNode pn=new ParseNode("task_parameter");
+               pn.addChild("optional").addChild(fp);
+               RESULT=pn;
+       :}              
+       
+       ;
+
+tag_expression_list ::= tag_expression:te {: 
+       ParseNode pn=new ParseNode("tag_expression_list");
+       pn.addChild(te);
+       RESULT=pn;
+       :}
+       | tag_expression_list:tel COMMA tag_expression:te {: 
+       tel.addChild(te);
+       RESULT=tel;
+       :}
+       ;
+
+tag_expression ::= IDENTIFIER:type IDENTIFIER:id {: 
+               ParseNode pn=new ParseNode("tag_expression");
+               pn.addChild("type").addChild(type);
+               pn.addChild("single").addChild(id);
+               RESULT=pn;
+       :}
+       ;
+
+tag_list_opt ::= LBRACE tag_list:fl RBRACE {:RESULT=fl;:}
+       | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}  
+       | {: RESULT = new ParseNode("empty"); :}
+       ;
+
+tag_list ::= tag_change:fc {: 
+               ParseNode pn=new ParseNode("tag_list");
+               pn.addChild(fc);
+               RESULT=pn;
+       :}
+       | tag_list:fl COMMA tag_change:fc {: 
+               fl.addChild(fc);
+               RESULT=fl;
+       :};
+
+tag_change ::= IDENTIFIER:id {: 
+               RESULT=new ParseNode("name").addChild(id).getRoot();
+       :}
+       | NOT IDENTIFIER:id {: 
+               RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
+       :};
+
+flag_expression ::= 
+       flag_andexpression:exp {: 
+               RESULT=exp;
+       :}
+       | flag_expression:exp1 OROR flag_andexpression:exp2 {: 
+               ParseNode pn=new ParseNode("or");
+               pn.addChild(exp1);
+               pn.addChild(exp2);
+               RESULT=pn;
+       :}
+       ;
+
+flag_andexpression ::= 
+       flag_notexpression:exp {: RESULT=exp; :}
+       | flag_notexpression:exp1 ANDAND flag_andexpression:exp2 {: 
+               ParseNode pn=new ParseNode("and");
+               pn.addChild(exp1);
+               pn.addChild(exp2);
+               RESULT=pn;
+       :}
+       ;
+
+flag_notexpression ::=
+       NOT flag_notexpression:exp {: 
+               ParseNode pn=new ParseNode("not");
+               pn.addChild(exp);
+               RESULT=pn;
+       :}
+       | LPAREN flag_expression:exp RPAREN {: 
+               RESULT=exp;
+       :}
+       | IDENTIFIER:id {:
+               ParseNode pn=new ParseNode("name");
+               pn.addChild(id);
+               RESULT=pn;
+       :}
+       ;
+
+task_exitstatement ::= TASKEXIT flag_effects_opt:opt cons_checks_opt:cco SEMICOLON {: 
+               RESULT=(new ParseNode("taskexit")).addChild(opt).getRoot().addChild(cco).getRoot();
+       :};
+
+cons_checks_opt ::= ASSERT LPAREN cons_checks:cc RPAREN {: RESULT=cc; :}
+       | {: RESULT = new ParseNode("empty"); :}
+       ;
+
+cons_checks ::= cons_check:cc {: 
+               ParseNode pn=new ParseNode("cons_checks");
+               pn.addChild(cc);
+               RESULT=pn;
+       :}
+       |       cons_checks:ccs COMMA cons_check:cc {: 
+               ccs.addChild(cc);
+               RESULT=ccs;
+       :};
+
+cons_check ::= IDENTIFIER:name LPAREN cons_argument_list_opt:args RPAREN {: 
+               ParseNode pn=new ParseNode("cons_check");
+               pn.addChild("name").addChild("identifier").addChild(name);
+               pn.addChild(args);
+               RESULT=pn;
+       :};
+
+flag_effects_opt ::= LPAREN flag_effects:fe RPAREN {:RESULT=fe;:}
+       | {: RESULT = new ParseNode("empty"); :}
+       ;
+
+flag_effects ::= flag_effect:fe {: 
+               ParseNode pn=new ParseNode("flag_effects_list");
+               pn.addChild(fe);
+               RESULT=pn;
+       :}
+       |       flag_effects:fes COMMA flag_effect:fe {: 
+               fes.addChild(fe);
+               RESULT=fes;
+       :};
+
+flag_effect ::= IDENTIFIER:id LBRACE flag_list:fl RBRACE tag_list_opt:tlo {: 
+               ParseNode pn=new ParseNode("flag_effect");
+               pn.addChild("name").addChild(id);
+               pn.addChild(fl);
+               pn.addChild(tlo);
+               RESULT=pn;
+       :}
+       | IDENTIFIER:id LBRACE RBRACE LBRACE tag_list:tl RBRACE {: 
+               ParseNode pn=new ParseNode("flag_effect");
+               pn.addChild("name").addChild(id);
+               pn.addChild(tl);
+               RESULT=pn;
+       :};
+
+flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
+       | LBRACE RBRACE {: RESULT = new ParseNode("empty"); :}  
+       | 
+       {: RESULT = new ParseNode("empty"); :}
+       ;
+
+flag_list ::= flag_change:fc {: 
+               ParseNode pn=new ParseNode("flag_list");
+               pn.addChild(fc);
+               RESULT=pn;
+       :}
+       |       flag_list:fl COMMA flag_change:fc {: 
+               fl.addChild(fc);
+               RESULT=fl;
+       :};
+
+flag_change ::= IDENTIFIER:id {: 
+               RESULT=new ParseNode("name").addChild(id).getRoot();
+       :} |
+       NOT IDENTIFIER:id {: 
+               RESULT=new ParseNode("not").addChild("name").addChild(id).getRoot();
+       :};
+
 // 19.2) The Syntactic Grammar
 goal ::=       compilation_unit:cu
        {:
@@ -268,6 +524,7 @@ literal ::= INTEGER_LITERAL:integer_lit
 type   ::=     primitive_type:type {: RESULT=type; :}
        |       reference_type:type {: RESULT=type; :}
        ;
+
 primitive_type ::=
                numeric_type:type {: RESULT=type; :}
        |       BOOLEAN {: RESULT=(new ParseNode("type")).addChild("boolean").getRoot(); :}
@@ -289,7 +546,7 @@ floating_point_type ::=
 
 reference_type ::=
                class_or_interface_type:type {: RESULT=type; :}
-//     |       array_type:type {: RESULT=type; :}
+       |       array_type:type {: RESULT=type; :}
        ;
 class_or_interface_type ::= name:name {: 
        RESULT=(new ParseNode("type")).addChild("class").addChild(name).getRoot(); 
@@ -298,9 +555,19 @@ class_or_interface_type ::= name:name {:
 class_type ::= class_or_interface_type:type {: RESULT=type; :};
 //interface_type ::= class_or_interface_type;
 
-//array_type ::=       primitive_type dims
-//     |       name dims
-//     ;
+array_type ::= primitive_type:prim dims:dims {: 
+               ParseNode pn=(new ParseNode("type")).addChild("array");
+               pn.addChild("basetype").addChild(prim);
+               pn.addChild("dims").setLiteral(dims);
+               RESULT=pn.getRoot();
+       :}
+       |       name:name dims:dims {: 
+               ParseNode pn=(new ParseNode("type")).addChild("array");
+               pn.addChild("basetype").addChild("type").addChild("class").addChild(name);
+               pn.addChild("dims").setLiteral(dims);
+               RESULT=pn.getRoot();
+       :}
+       ;
 
 // 19.5) Names
 name   ::=     simple_name:name {: RESULT=name; :}
@@ -320,26 +587,44 @@ qualified_name ::= name:name DOT IDENTIFIER:id {:
 
 // 19.6) Packages
 compilation_unit ::=
-//              package_declaration_opt
-//              import_declarations_opt
+                package_declaration_opt:pdo
+                import_declarations_opt:ido
                type_declarations_opt:tdo {: 
                ParseNode pn=new ParseNode("compilation_unit");
                pn.addChild(tdo);
+               pn.addChild("packages").addChild(pdo);
+               pn.addChild("imports").addChild(ido);
                RESULT=pn;
                :}
                ;
-//package_declaration_opt ::= package_declaration | ;
-//import_declarations_opt ::= import_declarations | ;
+package_declaration_opt ::= package_declaration:pdo {:
+               RESULT=pdo;
+       :} |
+       {: RESULT=new ParseNode("empty"); :}
+;
+
+import_declarations_opt ::= import_declarations:ido {: 
+               RESULT=ido;
+       :} | 
+       {: RESULT=new ParseNode("empty"); :}
+;
 type_declarations_opt   ::= type_declarations:tds {:
                RESULT=tds;
                :}   | 
        {: RESULT=new ParseNode("empty"); :}
        ;
 
-//import_declarations ::=
-//               import_declaration
-//       |       import_declarations import_declaration
-//       ;
+import_declarations ::=
+               import_declaration:id {: 
+               ParseNode pn=new ParseNode("import_decls_list");
+               pn.addChild(id);
+               RESULT=pn;
+       :}
+       |       import_declarations:ids import_declaration:id {: 
+               ids.addChild(id);
+               RESULT=ids;
+       :}
+       ;
 
 type_declarations ::= 
                type_declaration:td {:
@@ -353,25 +638,41 @@ type_declarations ::=
                :}
        ;
 
-//package_declaration ::=
-//               PACKAGE name SEMICOLON
-//       ;
-//import_declaration ::=
-//               single_type_import_declaration
-//       |       type_import_on_demand_declaration
-//       ;
-//single_type_import_declaration ::=
-//               IMPORT name SEMICOLON
-//       ;
-//type_import_on_demand_declaration ::=
-//               IMPORT name DOT MULT SEMICOLON
-//       ;
+package_declaration ::=
+               PACKAGE name:name SEMICOLON {: 
+       ParseNode pn=new ParseNode("package");
+       pn.addChild(name);
+       RESULT=pn;
+       :}
+       ;
+import_declaration ::=
+               single_type_import_declaration:sid {: RESULT=sid; :}
+       |       type_import_on_demand_declaration:iod {: RESULT=iod; :}
+       ;
+single_type_import_declaration ::=
+               IMPORT name:name SEMICOLON {: 
+       ParseNode pn=new ParseNode("import_single");
+       pn.addChild(name);
+       RESULT=pn;
+:}
+       ;
+type_import_on_demand_declaration ::=
+               IMPORT name:name DOT MULT SEMICOLON {:
+       ParseNode pn=new ParseNode("import_ondemand");
+       pn.addChild(name);
+       RESULT=pn;
+       :}       
+       ;
 
 type_declaration ::=
                class_declaration:cd 
                {:
                        RESULT=cd;
                :}
+       |       task_declaration:td 
+               {:
+                       RESULT=td;
+               :}
 //      |       interface_declaration
        |       SEMICOLON {: RESULT=new ParseNode("empty"); :}
        ;
@@ -400,8 +701,9 @@ modifier ::=
        STATIC {: RESULT=new ParseNode("static"); :} |
 //     ABSTRACT |
        FINAL {: RESULT=new ParseNode("final"); :}|
-       NATIVE {: RESULT=new ParseNode("native"); :}
-//     SYNCHRONIZED | 
+       NATIVE {: RESULT=new ParseNode("native"); :} |
+       SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :} |
+       ATOMIC {: RESULT=new ParseNode("atomic"); :}
 //     TRANSIENT | 
 //     VOLATILE |
 //     STRICTFP // note that semantic analysis must check that the
@@ -476,6 +778,11 @@ class_body_declaration ::=
 :}
        ;
 class_member_declaration ::=
+       //failure aware computation
+       flag_declaration:flag {: 
+       RESULT=(new ParseNode("flag")).addChild(flag).getRoot(); 
+       :}
+       |
        field_declaration:field {: 
        RESULT=(new ParseNode("field")).addChild(field).getRoot(); 
        :}
@@ -488,6 +795,21 @@ class_member_declaration ::=
        |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
        ;
 
+//Failure aware computation
+flag_declaration ::= 
+               FLAG IDENTIFIER:id SEMICOLON {: 
+               ParseNode pn=new ParseNode("flag_declaration");
+               pn.addChild("name").addChild(id);
+               RESULT=pn;
+       :}      |
+               EXTERNAL FLAG IDENTIFIER:id SEMICOLON {: 
+               ParseNode pn=new ParseNode("flag_declaration");
+               pn.addChild("name").addChild(id);
+               pn.addChild("external");
+               RESULT=pn;
+       :}
+       ;
+
 // 19.8.2) Field Declarations
 field_declaration ::= 
                modifiers_opt:mo type:type variable_declarators:var SEMICOLON {: 
@@ -496,6 +818,14 @@ field_declaration ::=
                pn.addChild("type").addChild(type);
                pn.addChild("variables").addChild(var);
                RESULT=pn;
+       :} |
+               modifiers_opt:mo GLOBAL type:type variable_declarators:var SEMICOLON {: 
+               ParseNode pn=new ParseNode("field_declaration");
+               pn.addChild("modifier").addChild(mo);
+               pn.addChild("type").addChild(type);
+               pn.addChild("variables").addChild(var);
+               pn.addChild("global");
+               RESULT=pn;
        :}
        ;
 
@@ -526,8 +856,8 @@ variable_declarator ::=
 variable_declarator_id ::=
                IDENTIFIER:id {: 
                RESULT=(new ParseNode("single")).addChild(id).getRoot();:}
-//     |       variable_declarator_id:id LBRACK RBRACK {:
-//             RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
+       |       variable_declarator_id:id LBRACK RBRACK {:
+               RESULT=(new ParseNode("array")).addChild(id).getRoot();:}
        ;
 variable_initializer ::=
                expression:exp {: RESULT=exp; :}
@@ -594,6 +924,12 @@ formal_parameter ::=
                pn.addChild(name);
                RESULT=pn;
        :}
+       |
+               TAG variable_declarator_id:name {:
+               ParseNode pn=new ParseNode("tag_parameter");
+               pn.addChild(name);
+               RESULT=pn;
+       :}
 //     |       FINAL type variable_declarator_id
        ;
 //throws_opt ::=       
@@ -626,6 +962,16 @@ constructor_declaration ::=
                pn.addChild(cd);
                pn.addChild("body").addChild(body);
                RESULT=pn;
+       :} |
+               modifiers_opt:mo GLOBAL constructor_declarator:cd
+//throws_opt 
+                       constructor_body:body   {:
+               ParseNode pn=new ParseNode("constructor_declaration");
+               pn.addChild("global");
+               pn.addChild("modifiers").addChild(mo);
+               pn.addChild(cd);
+               pn.addChild("body").addChild(body);
+               RESULT=pn;
        :}
        ;
 constructor_declarator ::=
@@ -637,8 +983,17 @@ constructor_declarator ::=
        :}
        ;
 constructor_body ::=
-//             LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE |
-//             LBRACE explicit_constructor_invocation RBRACE |
+               LBRACE explicit_constructor_invocation:eci block_statements:bs RBRACE {: 
+                       ParseNode pn=new ParseNode("constructor_body");
+                       pn.addChild(eci);
+                       pn.addChild(bs);
+                       RESULT=pn;
+       :} |
+               LBRACE explicit_constructor_invocation:eci RBRACE {: 
+                       ParseNode pn=new ParseNode("constructor_body");
+                       pn.addChild(eci);
+                       RESULT=pn;
+       :} |
                LBRACE block_statements:block RBRACE {: 
                ParseNode pn=new ParseNode("constructor_body");
                pn.addChild(block);
@@ -646,12 +1001,17 @@ constructor_body ::=
        :}
        |       LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
        ;
-//explicit_constructor_invocation ::=
+explicit_constructor_invocation ::=
 //             THIS LPAREN argument_list_opt RPAREN SEMICOLON
-//     |       SUPER LPAREN argument_list_opt RPAREN SEMICOLON
+//     |       
+SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {: 
+       ParseNode pn=new ParseNode("superinvoke");
+       pn.addChild(alo);
+       RESULT=pn;
+:}
 //     |       primary DOT THIS LPAREN argument_list_opt RPAREN SEMICOLON
 //     |       primary DOT SUPER LPAREN argument_list_opt RPAREN SEMICOLON
-//     ;
+       ;
 
 // 19.9) Interfaces
 
@@ -730,7 +1090,10 @@ block_statements ::=
        :}
        ;
 block_statement ::=
-               local_variable_declaration_statement:lvds {: 
+       tag_variable_declaration_statement:tvds {:
+               RESULT=tvds;
+       :}              
+       |       local_variable_declaration_statement:lvds {: 
                RESULT=lvds;
        :}
        |       statement:statement {: 
@@ -739,6 +1102,14 @@ block_statement ::=
 //     |       class_declaration
 //     |       interface_declaration
        ;
+tag_variable_declaration_statement ::=
+               TAG IDENTIFIER:id EQ NEW TAG LPAREN IDENTIFIER:type RPAREN SEMICOLON {: 
+               ParseNode pn=new ParseNode("tag_declaration");
+               pn.addChild("single").addChild(id);
+               pn.addChild("type").addChild(type);
+               RESULT=pn;
+       :}
+       ;
 local_variable_declaration_statement ::=
                local_variable_declaration:lvd SEMICOLON {: 
                RESULT=lvd;
@@ -774,10 +1145,12 @@ statement_without_trailing_substatement ::=
        |       empty_statement:st {: RESULT=st; :}
        |       expression_statement:st {: RESULT=st; :}
 //     |       switch_statement
-       |       do_statement
+       |       do_statement:dos {:RESULT=dos; :}
        |       break_statement:st {: RESULT=st; :}
        |       continue_statement:st {: RESULT=st; :}
        |       return_statement:st {: RESULT=st; :}
+       |       task_exitstatement:st {: RESULT=st; :}
+       |       atomic_statement:st {: RESULT=st; :}
 //     |       synchronized_statement
 //     |       throw_statement
 //     |       try_statement
@@ -955,6 +1328,11 @@ return_statement ::=
 //synchronized_statement ::=
 //             SYNCHRONIZED LPAREN expression RPAREN block
 //     ;
+atomic_statement ::=
+               ATOMIC block:blk {: 
+       RESULT=(new ParseNode("atomic")).addChild(blk).getRoot();
+       :}
+       ;
 //try_statement ::=
 //             TRY block catches
 //     |       TRY block catches_opt finally
@@ -978,8 +1356,12 @@ return_statement ::=
 // 19.12) Expressions
 primary ::=    primary_no_new_array:st {: 
                RESULT=st; :}
-//     |       array_creation_init
-//     |       array_creation_uninit
+//     |       array_creation_init:st {: 
+//             RESULT=st;
+//     :}
+       |       array_creation_uninit:st {:
+               RESULT=st;
+       :}
        ;
 primary_no_new_array ::=
                literal:lit {: RESULT=lit; :}
@@ -988,7 +1370,12 @@ primary_no_new_array ::=
        |       class_instance_creation_expression:exp {: RESULT=exp; :}
        |       field_access:exp {: RESULT=exp; :}
        |       method_invocation:exp {: RESULT=exp; :}
-//     |       array_access
+       |       array_access:exp {: RESULT=exp; :}
+       |       ISAVAILABLE LPAREN IDENTIFIER:id RPAREN {: 
+               ParseNode pn=new ParseNode("isavailable");
+               pn.addChild(id);
+               RESULT=pn;
+       :}
 //     |       primitive_type DOT CLASS
 //     |       VOID DOT CLASS
 //     |       array_type DOT CLASS
@@ -996,12 +1383,38 @@ primary_no_new_array ::=
 //     |       name DOT THIS
        ;
 class_instance_creation_expression ::=
-               NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN {: 
+               NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
                ParseNode pn=new ParseNode("createobject");
                pn.addChild(type);
                pn.addChild(args);
+               pn.addChild(feo);
+               RESULT=pn;
+       :} 
+       //Global object
+       | GLOBAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
+               ParseNode pn=new ParseNode("createobject");
+               pn.addChild(type);
+               pn.addChild(args);
+               pn.addChild(feo);
+               pn.addChild("global");
                RESULT=pn;
        :}
+       | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE RBRACE LBRACE tag_list:tl RBRACE {: 
+               ParseNode pn=new ParseNode("createobject");
+               pn.addChild(type);
+               pn.addChild(args);
+               pn.addChild(tl);
+               RESULT=pn;
+       :}
+       | NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN LBRACE flag_list:fl RBRACE LBRACE tag_list:tl RBRACE {: 
+               ParseNode pn=new ParseNode("createobject");
+               pn.addChild(type);
+               pn.addChild(args);
+               pn.addChild(fl);
+               pn.addChild(tl);
+               RESULT=pn;
+       :}
+
 //     |       NEW class_or_interface_type LPAREN argument_list_opt RPAREN class_body
 //     |       primary DOT NEW IDENTIFIER
 //                     LPAREN argument_list_opt RPAREN {: 
@@ -1014,40 +1427,99 @@ class_instance_creation_expression ::=
 //     |       name DOT NEW IDENTIFIER
 //                     LPAREN argument_list_opt RPAREN class_body
        ;
+cons_argument_list_opt ::=
+       {: RESULT=new ParseNode("empty"); :}
+       |       cons_argument_list:args {: RESULT=args; :}
+       ;
+
+cons_argument_list ::=
+               IDENTIFIER:id COLON expression:exp {:
+               ParseNode pn=new ParseNode("cons_argument_list");
+               ParseNode pnarg=pn.addChild("binding");
+               pnarg.addChild("var").addChild(id);
+               pnarg.addChild("exp").addChild(exp);
+               RESULT=pn;
+       :}
+       |       argument_list:list COMMA IDENTIFIER:id COLON expression:exp {:
+               ParseNode pnarg=new ParseNode("binding");
+               pnarg.addChild("var").addChild(id);
+               pnarg.addChild("exp").addChild(exp);
+               list.addChild(pnarg);
+               RESULT=list;
+       :}
+       ;
+
 argument_list_opt ::=
        {: RESULT=new ParseNode("empty"); :}
        |       argument_list:args {: RESULT=args; :}
        ;
+
 argument_list ::=
                expression:exp {:
                ParseNode pn=new ParseNode("argument_list");
                pn.addChild(exp);
                RESULT=pn;
        :}
-       |       argument_list:list COMMA expression:exp {: 
+       |       argument_list:list COMMA expression:exp {:
                list.addChild(exp);
                RESULT=list;
        :}
        ;
-//array_creation_uninit ::=
-//             NEW primitive_type dim_exprs dims_opt
-//     |       NEW class_or_interface_type dim_exprs dims_opt
-//     ;
+array_creation_uninit ::=
+               NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               RESULT=pn;
+               :}
+       |       NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               RESULT=pn;
+       :}
+       |       GLOBAL NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               pn.addChild("global");
+               RESULT=pn;
+               :}
+       |       GLOBAL NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               pn.addChild("global");
+               RESULT=pn;
+       :}
+       ;
 //array_creation_init ::=
 //             NEW primitive_type dims array_initializer
 //     |       NEW class_or_interface_type dims array_initializer
 //     ;
-//dim_exprs ::=        dim_expr
-//     |       dim_exprs dim_expr
-//     ;
-//dim_expr ::= LBRACK expression RBRACK
-//     ;
-//dims_opt ::=
-//     |       dims
-//     ;
-//dims ::=     LBRACK RBRACK
-//     |       dims LBRACK RBRACK
-//     ;
+dim_exprs ::=  dim_expr:exp {: 
+               ParseNode pn=new ParseNode("dim_exprs");
+               pn.addChild(exp);
+               RESULT=pn; :}
+       |       dim_exprs:base dim_expr:exp {: 
+               base.addChild(exp);
+               RESULT=base;
+       :}
+       ;
+dim_expr ::=   LBRACK expression:exp RBRACK {: RESULT=exp; :}
+       ;
+dims_opt ::= {: RESULT=new Integer(0); :}
+       |       dims:dims {: RESULT = dims; :}
+       ;
+
+dims ::=       LBRACK RBRACK {: RESULT=new Integer(1); :}
+       |       dims:dims LBRACK RBRACK {: RESULT=new Integer(dims.intValue()+1); :}
+       ;
+
 field_access ::=
                primary:base DOT IDENTIFIER:id {: 
                ParseNode pn=new ParseNode("fieldaccess");
@@ -1072,14 +1544,37 @@ method_invocation ::=
                pn.addChild(args);
                RESULT=pn;
        :}
-//     |       SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
+       |       SUPER DOT IDENTIFIER:id LPAREN argument_list_opt:args RPAREN {: 
+               ParseNode name=new ParseNode("name");
+               name.addChild("base").addChild("name").addChild("identifier").addChild("super");
+               name.addChild("identifier").addChild(id);
+               ParseNode pn=new ParseNode("methodinvoke1");
+               pn.addChild(name);
+               pn.addChild(args);
+               RESULT=pn;
+       :}
 //     |       name DOT SUPER DOT IDENTIFIER LPAREN argument_list_opt RPAREN
        ;
-//array_access ::=
-//             name LBRACK expression RBRACK
-//     |       primary_no_new_array LBRACK expression RBRACK
-//     |       array_creation_init LBRACK expression RBRACK
-//     ;
+array_access ::=
+               name:name LBRACK expression:exp RBRACK {: 
+               ParseNode pn=new ParseNode("arrayaccess");
+               pn.addChild("base").addChild(name);
+               pn.addChild("index").addChild(exp);
+               RESULT=pn;
+       :}
+       |       primary_no_new_array:base LBRACK expression:exp RBRACK {: 
+               ParseNode pn=new ParseNode("arrayaccess");
+               pn.addChild("base").addChild(base);
+               pn.addChild("index").addChild(exp);
+               RESULT=pn;
+       :}
+//     |       array_creation_init:init LBRACK expression:exp RBRACK {: 
+//             ParseNode pn=new ParseNode("arrayaccess");
+//             pn.addChild("init").addChild(init);
+//             pn.addChild("index").addChild(exp);
+//             RESULT=pn;
+//     :}
+       ;
 postfix_expression ::=
                primary:exp {: 
        RESULT=exp; :}
@@ -1116,7 +1611,8 @@ predecrement_expression ::=
 unary_expression_not_plus_minus ::=
                postfix_expression:exp {: 
                RESULT=exp; :}
-//     |       COMP unary_expression
+       |       COMP unary_expression:exp
+               {: RESULT=(new ParseNode("comp")).addChild(exp).getRoot(); :}
        |       NOT unary_expression:exp 
                {: RESULT=(new ParseNode("not")).addChild(exp).getRoot(); :}
        |       cast_expression:exp {: RESULT=exp; :}
@@ -1192,7 +1688,12 @@ shift_expression ::=
                pn.addChild(exp2);
                RESULT=pn;
        :}
-//     |       shift_expression URSHIFT additive_expression
+       |       shift_expression:exp1 URSHIFT additive_expression:exp2 {:
+               ParseNode pn=new ParseNode("urightshift");
+               pn.addChild(exp1);      
+               pn.addChild(exp2);      
+               RESULT=pn;
+       :}
        ;
 relational_expression ::=
                shift_expression:exp {: 
@@ -1324,7 +1825,7 @@ assignment_operator ::=
        |       MINUSEQ {: RESULT=new ParseNode("minuseq"); :}
        |       LSHIFTEQ {: RESULT=new ParseNode("lshifteq"); :}
        |       RSHIFTEQ {: RESULT=new ParseNode("rshifteq"); :}
-//     |       URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
+       |       URSHIFTEQ {: RESULT=new ParseNode("urshifteq"); :}
        |       ANDEQ {: RESULT=new ParseNode("andeq"); :}
        |       XOREQ {: RESULT=new ParseNode("xoreq"); :}
        |       OREQ {: RESULT=new ParseNode("oreq"); :}