예제 #1
0
 /**
  * Given ^(TOKEN_REF ^(OPTIONS ^(ELEMENT_OPTIONS (= assoc right)))) set option assoc=right in
  * TOKEN_REF.
  */
 public static void setNodeOptions(GrammarAST node, GrammarAST options) {
   GrammarASTWithOptions t = (GrammarASTWithOptions) node;
   if (t.getChildCount() == 0) return;
   for (Object o : options.getChildren()) {
     GrammarAST c = (GrammarAST) o;
     if (c.getType() == ANTLRParser.ASSIGN) {
       t.setOption(c.getChild(0).getText(), (GrammarAST) c.getChild(1));
     } else {
       t.setOption(c.getText(), null); // no arg such as ID<VarNodeType>
     }
   }
 }