Пример #1
0
  public boolean visit(AstNode node) {
    if (node instanceof AstRoot) return true;
    else {
      Tree t = buildTree(node);
      Tree p = trees.get(node.getParent());
      p.addChild(t);

      if (node instanceof Name) {
        Name name = (Name) node;
        t.setLabel(name.getIdentifier());
      } else if (node instanceof StringLiteral) {
        StringLiteral literal = (StringLiteral) node;
        t.setLabel(literal.getValue());
      } else if (node instanceof NumberLiteral) {
        NumberLiteral l = (NumberLiteral) node;
        t.setLabel(l.getValue());
      }

      return true;
    }
  }
Пример #2
0
 public void testParseUnicodeFormatStringLiteral() {
   AstRoot root = parse("'A\u200DB'");
   ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
   StringLiteral stringLit = (StringLiteral) st.getExpression();
   assertEquals("A\u200DB", stringLit.getValue());
 }