start of new file
[IRC.git] / Robust / src / Parse / java14.cup
index 5e457d583ff6d18b4ad175354f7a8645202b2718..85d18b58f97a95cf983e81df9cfcd597e166073f 100644 (file)
@@ -152,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;
@@ -221,6 +221,8 @@ 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;
@@ -251,6 +253,12 @@ 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;
 
 
@@ -296,6 +304,19 @@ task_parameter ::=
                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 {: 
@@ -681,7 +702,8 @@ modifier ::=
 //     ABSTRACT |
        FINAL {: RESULT=new ParseNode("final"); :}|
        NATIVE {: RESULT=new ParseNode("native"); :} |
-       SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :}
+       SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :} |
+       ATOMIC {: RESULT=new ParseNode("atomic"); :}
 //     TRANSIENT | 
 //     VOLATILE |
 //     STRICTFP // note that semantic analysis must check that the
@@ -796,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;
        :}
        ;
 
@@ -894,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 ::=       
@@ -926,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 ::=
@@ -937,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);
@@ -946,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
 
@@ -1090,6 +1150,7 @@ statement_without_trailing_substatement ::=
        |       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
@@ -1267,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
@@ -1305,6 +1371,11 @@ primary_no_new_array ::=
        |       field_access:exp {: RESULT=exp; :}
        |       method_invocation:exp {: RESULT=exp; :}
        |       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
@@ -1318,6 +1389,15 @@ class_instance_creation_expression ::=
                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");
@@ -1400,6 +1480,22 @@ array_creation_uninit ::=
                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
@@ -1448,7 +1544,15 @@ 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 ::=
@@ -1507,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; :}
@@ -1583,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 {: 
@@ -1715,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"); :}