start of new file
[IRC.git] / Robust / src / Parse / java14.cup
index f98ec7fb96bd35053323283d0889697c73262eb3..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;
@@ -222,6 +222,7 @@ non terminal ParseNode expression_opt, expression;
 //failure aware computation keywords
 terminal FLAG;
 terminal OPTIONAL;
+terminal ISAVAILABLE;
 terminal EXTERNAL;
 terminal TAG;
 terminal TASK;
@@ -254,7 +255,6 @@ non terminal ParseNode tag_change;
 
 //distributed transaction keywords
 terminal ATOMIC;
-terminal LOCAL;
 terminal GLOBAL;
 non terminal ParseNode atomic_statement;
 
@@ -962,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 ::=
@@ -973,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);
@@ -982,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
 
@@ -1305,8 +1329,8 @@ return_statement ::=
 //             SYNCHRONIZED LPAREN expression RPAREN block
 //     ;
 atomic_statement ::=
-               ATOMIC LPAREN expression:exp RPAREN block {: 
-       RESULT=(new ParseNode("atomic")).addChild(exp).getRoot();
+               ATOMIC block:blk {: 
+       RESULT=(new ParseNode("atomic")).addChild(blk).getRoot();
        :}
        ;
 //try_statement ::=
@@ -1347,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
@@ -1362,11 +1391,12 @@ class_instance_creation_expression ::=
                RESULT=pn;
        :} 
        //Global object
-       | LOCAL NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
+       | 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 {: 
@@ -1450,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
@@ -1498,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 ::=
@@ -1557,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; :}
@@ -1633,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 {: 
@@ -1765,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"); :}