extends grammar little more to have the break statement with label
authoryeom <yeom>
Sat, 23 Apr 2011 00:52:19 +0000 (00:52 +0000)
committeryeom <yeom>
Sat, 23 Apr 2011 00:52:19 +0000 (00:52 +0000)
Robust/src/IR/Tree/BuildIR.java
Robust/src/Parse/java14.cup

index 307796612f423bfbc0b18ab24bb429645b3c0b02..8aaf398fa55933710ea4793374d2cdbe6f66a3f8 100644 (file)
@@ -1481,7 +1481,9 @@ public class BuildIR {
       ContinueBreakNode cbn=new ContinueBreakNode(true);
       cbn.setNumLine(pn.getLine());
       blockstatements.add(cbn);
-
+      ParseNode idopt_pn=pn.getChild("identifier_opt");
+      ParseNode name_pn=idopt_pn.getChild("name");
+      // name_pn.getTerminal() gives you the label
     } else if (isNode(pn,"genreach")) {
       String graphName = pn.getChild("graphName").getTerminal();
       blockstatements.add( new GenReachNode( graphName ) );
index 75106cff3272ac855ba96e8bc9d501d3a2a41bde..87079c4f0bdd9e204fdc443a66c237de9a88b4d5 100644 (file)
@@ -194,7 +194,7 @@ non terminal ParseNode for_statement, for_statement_no_short_if;
 non terminal ParseNode for_init_opt, for_init;
 non terminal ParseNode for_update_opt, for_update;
 non terminal ParseNode statement_expression_list;
-//non terminal ParseNode identifier_opt;
+non terminal ParseNode identifier_opt;
 non terminal ParseNode break_statement, continue_statement;
 non terminal ParseNode return_statement;
 non terminal ParseNode throw_statement;
@@ -1771,14 +1771,21 @@ statement_expression_list ::=
        :}
        ;
 
-//identifier_opt ::= 
-//     |       IDENTIFIER
-//     ;
+identifier_opt ::= {: RESULT=new ParseNode("identifier_opt",parser.lexer.line_num);
+       :} 
+       |       IDENTIFIER:id {:
+               ParseNode pn=new ParseNode("identifier_opt",parser.lexer.line_num);
+               pn.addChild("name").addChild(id);
+               RESULT=pn;
+       :}
+       ;
 
 break_statement ::=
-               BREAK
-//identifier_opt 
-SEMICOLON {: RESULT=new ParseNode("break",parser.lexer.line_num); :}
+               BREAK identifier_opt:id SEMICOLON {: 
+               ParseNode pn=new ParseNode("break",parser.lexer.line_num);              
+               pn.addChild(id);
+               RESULT=pn;
+       :}
        ;
 
 continue_statement ::=