Add support for Enum type for mgc version and also add default constructor. Comment...
[IRC.git] / Robust / src / Parse / java14.cup
index 17c47a16d60fe6ec023bf7cd8099601e424fe1ec..2fd93f3f51d686020e65e2a1d416bb5eb048aedb 100644 (file)
@@ -52,11 +52,11 @@ terminal STATIC; // modifier
 terminal ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, TRANSIENT, VOLATILE;
 terminal CLASS; // class_declaration
 terminal EXTENDS; // super
-//terminal IMPLEMENTS; // interfaces
+terminal IMPLEMENTS; // interfaces
 terminal VOID; // method_header
 terminal THROWS; // throws
 terminal THIS, SUPER; // explicit_constructor_invocation
-//terminal INTERFACE; // interface_declaration
+terminal INTERFACE; // interface_declaration
 terminal IF, ELSE; // if_then_statement, if_then_else_statement
 terminal SWITCH; // switch_statement
 terminal CASE, DEFAULT; // switch_label
@@ -103,6 +103,9 @@ terminal ASSERT; // assert_statement
 terminal ELLIPSIS;
 terminal ENUM;
 
+// added for disjoint reachability analysis
+terminal GENREACH;
+
 
 // 19.2) The Syntactic Grammar
 non terminal ParseNode goal;
@@ -114,7 +117,7 @@ non terminal ParseNode integral_type, floating_point_type;
 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 interface_type;
 non terminal ParseNode array_type;
 // 19.5) Names
 non terminal ParseNode name, simple_name, qualified_name;
@@ -131,7 +134,7 @@ non terminal ParseNode type_declaration;
 non terminal ParseNode modifiers_opt, modifiers, modifier;
 // 19.8.1) Class Declaration
 non terminal ParseNode class_declaration, super, super_opt;
-//non terminal interfaces, interfaces_opt, interface_type_list;
+non terminal ParseNode interfaces, interfaces_opt, interface_type_list;
 non terminal ParseNode class_body;
 non terminal ParseNode class_body_declarations, class_body_declarations_opt;
 non terminal ParseNode class_body_declaration, class_member_declaration;
@@ -148,21 +151,21 @@ non terminal ParseNode formal_parameter;
 //non terminal ParseNode class_type_list;
 non terminal ParseNode method_body;
 // 19.8.4) Static Initializers
-//non terminal ParseNode static_initializer;
+non terminal ParseNode static_initializer;
 // 19.8.5) Constructor Declarations
 non terminal ParseNode constructor_declaration, constructor_declarator;
 non terminal ParseNode constructor_body;
 non terminal ParseNode explicit_constructor_invocation;
 // 19.9.1) Interface Declarations
-//non terminal ParseNode interface_declaration;
-//non terminal ParseNode extends_interfaces_opt, extends_interfaces;
-//non terminal ParseNode interface_body;
-//non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
-//non terminal ParseNode interface_member_declaration, constant_declaration;
-//non terminal ParseNode abstract_method_declaration;
+non terminal ParseNode interface_declaration;
+non terminal ParseNode extends_interfaces_opt, extends_interfaces;
+non terminal ParseNode interface_body;
+non terminal ParseNode interface_member_declarations_opt, interface_member_declarations;
+non terminal ParseNode interface_member_declaration, constant_declaration;
+non terminal ParseNode abstract_method_declaration;
 // 19.10) Arrays
-//non terminal ParseNode array_initializer;
-//non terminal ParseNode variable_initializers;
+non terminal ParseNode array_initializer;
+non terminal ParseNode variable_initializers;
 // 19.11) Blocks and Statements
 non terminal ParseNode block;
 non terminal ParseNode block_statements_opt, block_statements, block_statement;
@@ -174,10 +177,10 @@ non terminal ParseNode empty_statement;
 non terminal ParseNode expression_statement, statement_expression;
 non terminal ParseNode if_then_statement;
 non terminal ParseNode if_then_else_statement, if_then_else_statement_no_short_if;
-//non terminal ParseNode switch_statement, switch_block;
-//non terminal ParseNode switch_block_statement_groups;
-//non terminal ParseNode switch_block_statement_group;
-//non terminal ParseNode switch_labels, switch_label;
+non terminal ParseNode switch_statement, switch_block;
+non terminal ParseNode switch_block_statement_groups;
+non terminal ParseNode switch_block_statement_group;
+non terminal ParseNode switch_labels, switch_label;
 non terminal ParseNode while_statement, while_statement_no_short_if;
 non terminal ParseNode do_statement;
 non terminal ParseNode for_statement, for_statement_no_short_if;
@@ -188,11 +191,13 @@ non terminal ParseNode statement_expression_list;
 non terminal ParseNode break_statement, continue_statement;
 non terminal ParseNode return_statement;
 //non terminal ParseNode throw_statement;
-//non terminal ParseNode synchronized_statement, try_statement;
+non terminal ParseNode synchronized_statement;
+//non terminal ParseNode try_statement;
 //non terminal ParseNode catches_opt;
 //non terminal ParseNode catches, catch_clause;
 //non terminal ParseNode finally;
 //non terminal ParseNode assert_statement;
+non terminal ParseNode genreach_statement;
 // 19.12) Expressions
 non terminal ParseNode primary, primary_no_new_array;
 non terminal ParseNode class_instance_creation_expression;
@@ -218,7 +223,7 @@ non terminal ParseNode assignment_expression;
 non terminal ParseNode assignment;
 non terminal ParseNode assignment_operator;
 non terminal ParseNode expression_opt, expression;
-//non terminal ParseNode constant_expression;
+non terminal ParseNode constant_expression;
 //failure aware computation keywords
 terminal FLAG;
 terminal OPTIONAL;
@@ -256,6 +261,7 @@ non terminal ParseNode tag_change;
 //distributed transaction keywords
 terminal ATOMIC;
 terminal GLOBAL;
+terminal SCRATCH;
 terminal GETOFFSET;
 non terminal ParseNode atomic_statement;
 non terminal ParseNode getoffset_expression;
@@ -265,8 +271,15 @@ terminal DISJOINT;
 
 //coarse-grain parallelization
 terminal SESE;
+terminal RBLOCK;
 non terminal ParseNode sese_statement;
 
+// mgc
+// JSR-201) Enum Declaration
+non terminal ParseNode enum_declaration;
+non terminal ParseNode enum_body, enum_constants_opt, enum_constants, enum_constant;
+//non terminal ParseNode enum_arguments_opt, enum_body_declarations_opt;
+
 
 start with goal;
 
@@ -508,7 +521,7 @@ literal ::= INTEGER_LITERAL:integer_lit
        |       BOOLEAN_LITERAL:boolean_lit
        {:
                ParseNode pn=new ParseNode("literal");
-               pn.addChild("boole\1aan").setLiteral(boolean_lit);
+               pn.addChild("boolean").setLiteral(boolean_lit);
                RESULT=pn;
        :}
        |       CHARACTER_LITERAL:char_lit
@@ -562,7 +575,7 @@ class_or_interface_type ::= name:name {:
        :};
 
 class_type ::= class_or_interface_type:type {: RESULT=type; :};
-//interface_type ::= class_or_interface_type;
+interface_type ::= class_or_interface_type:type {: RESULT=type; :};
 
 array_type ::= primitive_type:prim dims:dims {: 
                ParseNode pn=(new ParseNode("type")).addChild("array");
@@ -678,11 +691,18 @@ type_declaration ::=
                {:
                        RESULT=cd;
                :}
+       |       enum_declaration:ed
+           {:
+               RESULT=ed;
+           :}
        |       task_declaration:td 
                {:
                        RESULT=td;
                :}
-//      |       interface_declaration
+    |   interface_declaration:in
+        {:
+                       RESULT=in;
+               :}
        |       SEMICOLON {: RESULT=new ParseNode("empty"); :}
        ;
 
@@ -708,13 +728,14 @@ modifier ::=
        PROTECTED {: RESULT=new ParseNode("protected"); :}|
        PRIVATE {: RESULT=new ParseNode("private"); :}|
        STATIC {: RESULT=new ParseNode("static"); :} |
-//     ABSTRACT |
+       ABSTRACT {: RESULT=new ParseNode("abstract"); :}  |
        FINAL {: RESULT=new ParseNode("final"); :}|
        NATIVE {: RESULT=new ParseNode("native"); :} |
        SYNCHRONIZED {: RESULT=new ParseNode("synchronized"); :} |
-       ATOMIC {: RESULT=new ParseNode("atomic"); :}
+       ATOMIC {: RESULT=new ParseNode("atomic"); :} |
+       VOLATILE {: RESULT=new ParseNode("volatile"); :}
 //     TRANSIENT | 
-//     VOLATILE |
+
 //     STRICTFP // note that semantic analysis must check that the
                         // context of the modifier allows strictfp.
        ;
@@ -723,13 +744,14 @@ modifier ::=
 
 // 19.8.1) Class Declaration:
 class_declaration ::= 
-       modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so //interfaces_opt
-class_body:body 
+       modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo 
+       class_body:body 
        {:
        ParseNode pn=new ParseNode("class_declaration");
        pn.addChild("modifiers").addChild(mo);
        pn.addChild("name").addChild(id);
        pn.addChild("super").addChild(so);
+       pn.addChild("superIF").addChild(ifo);
        pn.addChild("classbody").addChild(body);
        RESULT=pn;
        :}
@@ -745,15 +767,23 @@ super_opt ::=
        :}
        ;
 
-//interfaces ::= IMPLEMENTS interface_type_list
-//       ;
-//interfaces_opt::=
-//       |       interfaces
-//       ;
-//interface_type_list ::=
-//               interface_type
-//       |       interface_type_list COMMA interface_type
-//       ;
+interfaces ::= IMPLEMENTS interface_type_list:iftl {: RESULT=iftl; :}
+       ;
+interfaces_opt ::=
+       {: RESULT=new ParseNode("empty"); :}
+       |       interfaces:ifs {: RESULT=ifs; :}
+       ;
+interface_type_list ::=
+               interface_type:ift {: 
+                       ParseNode pn=new ParseNode("interface_type_list");
+                       pn.addChild(ift);
+                       RESULT=pn;
+               :}
+       |       interface_type_list:iftl COMMA interface_type:ift {: 
+                       iftl.addChild(ift);
+                       RESULT=iftl;
+               :}
+       ;
 
 class_body ::= LBRACE class_body_declarations_opt:cbdo RBRACE {: RESULT=cbdo; :}
        ;
@@ -778,7 +808,9 @@ class_body_declaration ::=
                class_member_declaration:member {: 
                RESULT=(new ParseNode("member")).addChild(member).getRoot();
        :}
-//     |       static_initializer
+       |       static_initializer:block{:
+               RESULT=(new ParseNode("static_block")).addChild(block).getRoot();
+       :}
        |       constructor_declaration:constructor {: 
                RESULT=(new ParseNode("constructor")).addChild(constructor).getRoot();
        :}
@@ -799,10 +831,75 @@ class_member_declaration ::=
        RESULT=(new ParseNode("method")).addChild(method).getRoot(); 
        :}
        /* repeat the prod for 'class_declaration' here: */
-//     |       modifiers_opt CLASS IDENTIFIER super_opt class_body
-//      |       interface_declaration
+       |       modifiers_opt:mo CLASS IDENTIFIER:id super_opt:so interfaces_opt:ifo class_body:body
+       {:
+       ParseNode pn=new ParseNode("inner_class_declaration");
+       pn.addChild("modifiers").addChild(mo);
+       pn.addChild("name").addChild(id);
+       pn.addChild("super").addChild(so);
+       pn.addChild("superIF").addChild(ifo);
+       pn.addChild("classbody").addChild(body);
+       RESULT=pn;
+       :}
+       |       enum_declaration:ed
+       {:
+       RESULT=ed; 
+       :}
+//    |       interface_declaration:interfaced {: 
+//     RESULT=(new ParseNode("interface")).addChild(interfaced).getRoot(); 
+//     :}
        |       SEMICOLON       {: RESULT=new ParseNode("empty"); :}
        ;
+       
+// mgc
+// JSR-201) Enum Declaration
+enum_declaration ::=
+               modifiers_opt:mo ENUM IDENTIFIER:id /*interfaces_opt:io*/ enum_body:body
+               {:
+                       ParseNode pn=new ParseNode("enum_declaration");
+                       pn.addChild("modifiers").addChild(mo);
+                       pn.addChild("name").addChild(id);
+                       //pn.addChild("superIF").addChild(ifo);
+                       pn.addChild("enumbody").addChild(body);
+                       RESULT=pn;
+               :}
+       ;
+enum_body ::=
+               LBRACE enum_constants_opt:eco /*enum_body_declarations_opt:ebdo*/ RBRACE
+               {: RESULT=eco; :}
+       ;
+enum_constants_opt ::=
+  {: RESULT=new ParseNode("empty"); :}
+       |       enum_constants:ecs
+       {: RESULT=ecs; :}
+       ;
+enum_constants ::=
+               enum_constant:ec {: 
+               ParseNode pn=new ParseNode("enum_constants_list");
+               pn.addChild(ec);
+               RESULT=pn;
+       :}
+       |       enum_constants:ecs COMMA enum_constant:ec {:
+           ecs.addChild(ec);
+           RESULT=ecs;
+       :}
+       ;
+enum_constant ::=
+               IDENTIFIER:id /*enum_arguments_opt*/
+               {: 
+                   ParseNode pn=new ParseNode("enum_constant");
+                   pn.addChild("name").addChild(id);
+                   RESULT=pn; 
+               :}
+//     |       IDENTIFIER enum_arguments_opt class_body
+       ;
+//enum_arguments_opt ::=
+//     |       LPAREN argument_list_opt RPAREN
+//     ;
+//enum_body_declarations_opt ::=
+//     |       SEMICOLON class_body_declarations_opt:cbdo
+//     ;
+
 
 //Failure aware computation
 flag_declaration ::= 
@@ -870,7 +967,7 @@ variable_declarator_id ::=
        ;
 variable_initializer ::=
                expression:exp {: RESULT=exp; :}
-//     |       array_initializer
+       |       array_initializer {: RESULT=new ParseNode("array_initializer"); :}
        ;
 
 // 19.8.3) Method Declarations
@@ -939,7 +1036,12 @@ formal_parameter ::=
                pn.addChild(name);
                RESULT=pn;
        :}
-//     |       FINAL type variable_declarator_id
+       |       FINAL type:type variable_declarator_id:name {:
+               ParseNode pn=new ParseNode("formal_parameter");
+               pn.addChild(type);
+               pn.addChild(name);
+               RESULT=pn;
+       :}
        ;
 //throws_opt ::=       
 //     |       throws
@@ -957,9 +1059,13 @@ method_body ::=   block:block {:
        ;
 
 // 19.8.4) Static Initializers
-//static_initializer ::=
-//             STATIC block
-//     ;
+static_initializer ::=
+               STATIC block:body {:
+               ParseNode pn=new ParseNode("static_block_declaration");
+               pn.addChild("body").addChild(body);
+               RESULT=pn;
+       :}
+       ;
 
 // 19.8.5) Constructor Declarations
 constructor_declaration ::=
@@ -982,7 +1088,8 @@ constructor_declaration ::=
                pn.addChild("body").addChild(body);
                RESULT=pn;
        :}
-       ;
+;
+
 constructor_declarator ::=
                simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {: 
                ParseNode pn=new ParseNode("constructor_declarator");
@@ -1011,8 +1118,12 @@ constructor_body ::=
        |       LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
        ;
 explicit_constructor_invocation ::=
-//             THIS LPAREN argument_list_opt RPAREN SEMICOLON
-//     |       
+       THIS LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
+            ParseNode pn=new ParseNode("explconstrinv");
+            pn.addChild(alo);
+            RESULT=pn;
+       :}
+       |       
 SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {: 
        ParseNode pn=new ParseNode("superinvoke");
        pn.addChild(alo);
@@ -1025,56 +1136,112 @@ SUPER LPAREN argument_list_opt:alo RPAREN SEMICOLON {:
 // 19.9) Interfaces
 
 // 19.9.1) Interface Declarations
-//interface_declaration ::=
-//               modifiers_opt INTERFACE IDENTIFIER extends_interfaces_opt
-//                       interface_body
-//       ;
-//extends_interfaces_opt ::=
-//       |       extends_interfaces
-//       ;
-//extends_interfaces ::=
-//               EXTENDS interface_type
-//       |       extends_interfaces COMMA interface_type
-//       ;
-//interface_body ::=
-//               LBRACE interface_member_declarations_opt RBRACE
-//       ;
-//interface_member_declarations_opt ::=
-//       |       interface_member_declarations
-//       ;
-//interface_member_declarations ::=
-//               interface_member_declaration
-//       |       interface_member_declarations interface_member_declaration
-//       ;
-//interface_member_declaration ::=
-//               constant_declaration
-//       |       abstract_method_declaration
-//       |       class_declaration
-//       |       interface_declaration
-//       |       SEMICOLON
-//       ;
-//constant_declaration ::=
-//               field_declaration
-//       // need to semantically check that modifiers of field declaration
-//       // include only PUBLIC, STATIC, or FINAL.  Other modifiers are
-//       // disallowed.
-//       ;
-//abstract_method_declaration ::=
-//               method_header SEMICOLON
-//       ;
+interface_declaration ::=
+               modifiers_opt:mo INTERFACE IDENTIFIER:id extends_interfaces_opt:io
+                       interface_body:body
+       {:
+       ParseNode pn=new ParseNode("interface_declaration");
+       pn.addChild("modifiers").addChild(mo);
+       pn.addChild("name").addChild(id);
+       pn.addChild("superIF").addChild(io);
+       pn.addChild("interfacebody").addChild(body);
+       RESULT=pn;
+       :}
+       ;
+extends_interfaces_opt ::=
+       {: RESULT=new ParseNode("empty"); :}
+       |       extends_interfaces:eifs {: RESULT=eifs; :}
+       ;
+extends_interfaces ::=
+               EXTENDS interface_type:ift 
+               {: 
+               ParseNode pn=new ParseNode("extend_interface_list");
+               pn.addChild(ift);
+               RESULT=pn; 
+               :}
+     |       extends_interfaces:eifs COMMA interface_type:ift
+             {:
+             eifs.addChild(ift);
+             RESULT=eifs;
+             :}
+       ;
+interface_body ::=
+               LBRACE interface_member_declarations_opt:imdo RBRACE
+               {: RESULT=imdo; :}
+       ;
+interface_member_declarations_opt ::=
+       {: RESULT=new ParseNode("empty"); :}
+       |       interface_member_declarations:imd {: RESULT=imd; :}
+       ;
+interface_member_declarations ::=
+               interface_member_declaration:imd {: 
+                       ParseNode pn=new ParseNode("interface_member_declaration_list");
+                       pn.addChild(imd);
+                       RESULT=pn;
+               :}
+       |       interface_member_declarations:imds interface_member_declaration:imd {: 
+                       imds.addChild(imd);
+                       RESULT=imds;
+               :}
+       ;
+interface_member_declaration ::=
+               constant_declaration:constant {: 
+               RESULT=(new ParseNode("constant")).addChild(constant).getRoot();
+       :}
+       |       abstract_method_declaration:method {:
+       RESULT=(new ParseNode("method")).addChild(method).getRoot(); 
+       :}
+          |    enum_declaration:ed {:
+          RESULT=(new ParseNode("enum_declaration")).addChild(ed).getRoot();
+          :}
+//       |       class_declaration:class 
+//       |       interface_declaration:interface 
+       |       SEMICOLON {: 
+       RESULT=new ParseNode("empty"); 
+       :}
+       ;
+constant_declaration ::=
+               field_declaration:fd {: RESULT=fd; :}
+       // need to semantically check that modifiers of field declaration
+       // include only PUBLIC, STATIC, or FINAL.  Other modifiers are
+       // disallowed.
+       ;
+abstract_method_declaration ::=
+               method_header:header SEMICOLON {:
+               ParseNode pn=new ParseNode("method_declaration");
+               pn.addChild("header").addChild(header);
+               pn.addChild("body").addChild(new ParseNode("empty"));
+               RESULT=pn;
+       :}
+       ;
 
 
 // 19.10) Arrays
-//array_initializer ::=
-//             LBRACE variable_initializers COMMA RBRACE
-//     |       LBRACE variable_initializers RBRACE
-//     |       LBRACE COMMA RBRACE
-//     |       LBRACE RBRACE
-//     ;
-//variable_initializers ::=
-//             variable_initializer
-//     |       variable_initializers COMMA variable_initializer
-//     ;
+array_initializer ::=
+               LBRACE variable_initializers:var_init_list COMMA RBRACE {:
+                      RESULT=var_init_list;
+               :}
+       |       LBRACE variable_initializers:var_init_list RBRACE {:
+                      RESULT=var_init_list;
+               :}
+       |       LBRACE COMMA RBRACE {:
+                      RESULT=new ParseNode("empty");                  
+               :}
+       |       LBRACE RBRACE {:
+                      RESULT=new ParseNode("empty");
+               :}
+       ;
+variable_initializers ::=
+               variable_initializer:var_init {:
+                      ParseNode pn=new ParseNode("var_init_list");
+                      pn.addChild(var_init);
+                      RESULT=pn;
+               :}
+       |       variable_initializers:var_init_list COMMA variable_initializer:var_init {:
+                      var_init_list.addChild(var_init);
+                      RESULT=var_init_list;
+               :}
+       ;
 
 // 19.11) Blocks and Statements
 block ::=      LBRACE block_statements_opt:bso RBRACE {: 
@@ -1108,6 +1275,9 @@ block_statement ::=
        |       statement:statement {: 
                RESULT=statement;
        :}
+//     |       enum_declaration:ed {:
+//             RESULT=ed;
+//     :}
 //     |       class_declaration
 //     |       interface_declaration
        ;
@@ -1130,8 +1300,13 @@ local_variable_declaration ::=
                pn.addChild(type);
                pn.addChild(var);
                RESULT=pn;
-:}
-//     |       FINAL type variable_declarators
+       :}
+       |       FINAL type:type variable_declarators:var {: 
+               ParseNode pn=new ParseNode("local_variable_declaration");
+               pn.addChild(type);
+               pn.addChild(var);
+               RESULT=pn;
+       :}
        ;
 statement ::=  statement_without_trailing_substatement:st {: 
                RESULT=st;
@@ -1153,7 +1328,7 @@ statement_without_trailing_substatement ::=
                block:st {: RESULT=st; :}
        |       empty_statement:st {: RESULT=st; :}
        |       expression_statement:st {: RESULT=st; :}
-//     |       switch_statement
+       |       switch_statement:st {: RESULT=st; :}
        |       do_statement:dos {:RESULT=dos; :}
        |       break_statement:st {: RESULT=st; :}
        |       continue_statement:st {: RESULT=st; :}
@@ -1161,7 +1336,8 @@ statement_without_trailing_substatement ::=
        |       task_exitstatement:st {: RESULT=st; :}
        |       atomic_statement:st {: RESULT=st; :}
        |       sese_statement:st {: RESULT=st; :}
-//     |       synchronized_statement
+       |       synchronized_statement:st {: RESULT=st; :}
+       |       genreach_statement:st {: RESULT=st; :}
 //     |       throw_statement
 //     |       try_statement
 //     |       assert_statement
@@ -1218,30 +1394,86 @@ if_then_else_statement_no_short_if ::=
                RESULT=pn;
        :}
        ;
-//switch_statement ::=
-//             SWITCH LPAREN expression RPAREN switch_block
-//     ;
-//switch_block ::=
-//             LBRACE switch_block_statement_groups switch_labels RBRACE
-//     |       LBRACE switch_block_statement_groups RBRACE
-//     |       LBRACE switch_labels RBRACE
-//     |       LBRACE RBRACE
-//     ;
-//switch_block_statement_groups ::=
-//             switch_block_statement_group
-//     |       switch_block_statement_groups switch_block_statement_group
-//     ;
-//switch_block_statement_group ::=
-//             switch_labels block_statements
-//     ;
-//switch_labels ::=
-//             switch_label
-//     |       switch_labels switch_label
-//     ;
-//switch_label ::=
-//             CASE constant_expression COLON
-//     |       DEFAULT COLON
-//     ;
+switch_statement ::=
+               SWITCH LPAREN expression:exp RPAREN switch_block:body
+               {:
+                   ParseNode pn=new ParseNode("switch_statement");
+                   pn.addChild("condition").addChild(exp);
+                   pn.addChild("statement").addChild(body);
+                   RESULT=pn;
+               :}
+       ;
+switch_block ::=
+               LBRACE switch_block_statement_groups:sbsg switch_labels:sl RBRACE
+               {: 
+                   ParseNode pn = new ParseNode("switch_block");
+                   pn.addChild("switch_labels").addChild(sl);
+                   pn.addChild("switch_statements").addChild(new ParseNode("empty"));
+                   sbsg.addChild(pn);
+                   RESULT=sbsg; 
+               :}
+       |       LBRACE switch_block_statement_groups:sbsg RBRACE
+           {: 
+                   RESULT=sbsg; 
+               :}
+       |       LBRACE switch_labels:sl RBRACE 
+           {: 
+               ParseNode pnb = new ParseNode("switch_block_list");
+                   ParseNode pn = new ParseNode("switch_block");
+                   pn.addChild("switch_labels").addChild(sl);
+                   pn.addChild("switch_statements").addChild(new ParseNode("empty"));
+                   pnb.addChild(pn);
+                   RESULT=pnb; 
+               :}
+       |       LBRACE RBRACE {: RESULT=new ParseNode("empty"); :}
+       ;
+switch_block_statement_groups ::=
+               switch_block_statement_group:sbsg
+               {: 
+                   ParseNode pn = new ParseNode("switch_block_list");
+                   pn.addChild(sbsg);
+                   RESULT=pn;
+               :}
+       |       switch_block_statement_groups:sbsgs switch_block_statement_group:sbsg
+           {:
+               sbsgs.addChild(sbsg);
+               RESULT=sbsgs;
+           :}
+       ;
+switch_block_statement_group ::=
+               switch_labels:sls block_statements:body
+               {: 
+                   ParseNode pn=new ParseNode("switch_block");
+                   pn.addChild("switch_labels").addChild(sls);
+                   pn.addChild("switch_statements").addChild(body);
+                   RESULT=pn; 
+               :}
+       ;
+switch_labels ::=
+               switch_label:sl
+               {: 
+                   ParseNode pn=new ParseNode("switch_label_list");
+                   pn.addChild(sl);
+                   RESULT=pn; 
+               :}
+       |       switch_labels:sls switch_label:sl
+           {: 
+                   sls.addChild(sl); 
+                   RESULT=sls;
+               :}
+       ;
+switch_label ::=
+               CASE constant_expression:ce COLON
+               {: 
+                   ParseNode pn=new ParseNode("switch_label");
+                   pn.addChild(ce);
+                   RESULT=pn;
+               :}
+       |       DEFAULT COLON
+           {: 
+                   RESULT=new ParseNode("default_switch_label"); 
+               :}
+       ;
 
 while_statement ::=
                WHILE LPAREN expression:exp RPAREN statement:st {: 
@@ -1335,26 +1567,42 @@ return_statement ::=
 //throw_statement ::=
 //             THROW expression SEMICOLON
 //     ;
-//synchronized_statement ::=
-//             SYNCHRONIZED LPAREN expression RPAREN block
-//     ;
+synchronized_statement ::=
+               SYNCHRONIZED LPAREN expression:e RPAREN block:b {: 
+               ParseNode pn=new ParseNode("synchronized");
+               pn.addChild("expr").addChild(e);
+               pn.addChild("block").addChild(b);
+               RESULT=pn;
+               :}
+       ;
 atomic_statement ::=
                ATOMIC block:blk {: 
        RESULT=(new ParseNode("atomic")).addChild(blk).getRoot();
        :}
        ;
 sese_statement ::=
-
-//            SESE variable_declarator_id:id LBRACE statement:st RBRACE {: 
-
               SESE block:blk {: 
               ParseNode pn = new ParseNode("sese");
-
-//            pn.addChild("identifier").addChild(id);
-
               pn.addChild("body").addChild(blk);
               RESULT=pn;
        :}
+       |      SESE variable_declarator_id:id block:blk {: 
+              ParseNode pn = new ParseNode("sese");
+              pn.addChild("body").addChild(blk);
+              pn.addChild("identifier").addChild(id);
+              RESULT=pn;
+       :}
+       |      RBLOCK block:blk {: 
+              ParseNode pn = new ParseNode("sese");
+              pn.addChild("body").addChild(blk);
+              RESULT=pn;
+       :}
+       |      RBLOCK variable_declarator_id:id block:blk {: 
+              ParseNode pn = new ParseNode("sese");
+              pn.addChild("body").addChild(blk);
+              pn.addChild("identifier").addChild(id);
+              RESULT=pn;
+       :}
        ;
 //try_statement ::=
 //             TRY block catches
@@ -1422,6 +1670,14 @@ class_instance_creation_expression ::=
                pn.addChild("global");
                RESULT=pn;
        :}
+       | SCRATCH 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("scratch");
+               RESULT=pn;
+       :}
        // Objects we want to track in disjointness analysis
        | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
                ParseNode pn=new ParseNode("createobject");
@@ -1520,6 +1776,14 @@ array_creation_uninit ::=
                pn.addChild("global");
                RESULT=pn;
                :}
+       |       SCRATCH 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("scratch");
+               RESULT=pn;
+               :}
        |       DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
                ParseNode pn=new ParseNode("createarray");
                pn.addChild(type);
@@ -1536,6 +1800,14 @@ array_creation_uninit ::=
                pn.addChild("global");
                RESULT=pn;
                :}
+       |       SCRATCH 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("scratch");
+               RESULT=pn;
+               :}
        |       DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
                ParseNode pn=new ParseNode("createarray");
                pn.addChild(type);
@@ -1667,11 +1939,16 @@ unary_expression_not_plus_minus ::=
        |       cast_expression:exp {: RESULT=exp; :}
        ;
 cast_expression ::=
-               LPAREN primitive_type:type
-       //dims_opt 
+               LPAREN primitive_type:type dims_opt:dims
                RPAREN unary_expression:exp {: 
                ParseNode pn=new ParseNode("cast1");
+if (dims.intValue()==0)
                pn.addChild("type").addChild(type);
+else {
+               ParseNode arrayt=pn.addChild("type").addChild("type").addChild("array");
+               arrayt.addChild("basetype").addChild(type);
+               arrayt.addChild("dims").setLiteral(dims);
+}
                pn.addChild("exp").addChild(exp);
                RESULT=pn;
        :}
@@ -1771,7 +2048,12 @@ relational_expression ::=
                pn.addChild(exp2);
                RESULT=pn;
        :}
-//     |       relational_expression INSTANCEOF reference_type
+       |       relational_expression:exp INSTANCEOF reference_type:type {: 
+               ParseNode pn=new ParseNode("instanceof");
+               pn.addChild("exp").addChild(exp);
+               pn.addChild(type);
+               RESULT=pn;
+       :}
        ;
 
 equality_expression ::=
@@ -1850,7 +2132,7 @@ conditional_expression ::=
                        pn.addChild("cond").addChild(condor);
                        pn.addChild("trueexpr").addChild(exptrue);
                        pn.addChild("falseexpr").addChild(expfalse);
-                       RETULT=pn;
+                       RESULT=pn;
                        :}
        ;
 getoffset_expression ::=
@@ -1904,6 +2186,21 @@ expression_opt ::=
 expression ::= assignment_expression:exp {: 
                RESULT=exp; :}
        ;
-//constant_expression ::=
-//             expression
-//     ;
+// note that this constraint must be enforced during semantic checking
+// 'constant_expression' should include enumerated constants.
+constant_expression ::=
+               expression:exp 
+               {:
+                   ParseNode pn = new ParseNode("constant_expression");
+                   pn.addChild(exp);
+                   RESULT=pn;
+               :}
+       ;
+
+
+genreach_statement ::=
+               GENREACH IDENTIFIER:graphName SEMICOLON {: 
+               ParseNode pn=new ParseNode("genreach");
+               pn.addChild("graphName").addChild(graphName);
+               RESULT=pn; :}
+       ;