コード例 #1
0
  @Override
  public Node Build(Tree parseTree, ASTBuilder buildHelper) throws SyntaxException {

    if (parseTree.subtrees.size() == 1) {
      return buildHelper.build(parseTree.subtrees.get(0), Expression.class);
    } else {
      Expression operand1 = buildHelper.build(parseTree.subtrees.get(0), Expression.class);

      Token operatorToken = (Token) parseTree.subtrees.get(1).root;
      BinaryOp.BinaryOps operator = BinaryOp.BinaryOps.find(operatorToken.text);

      Expression operand2 = buildHelper.build(parseTree.subtrees.get(2), Expression.class);

      return (new BinaryOp(operatorToken.line, operand1, operator, operand2));
    }
  }
コード例 #2
0
  @Override
  public Node Build(Tree parseTree, ASTBuilder buildHelper) throws SyntaxException {

    return (new Program(
        buildHelper.depthBuild(
            parseTree,
            new String[] {"Program"},
            new String[] {"CLASS", "CLASSEXT"},
            DeclClass.class)));
  }
  @Override
  public Node Build(Tree parseTree, ASTBuilder buildHelper) throws SyntaxException {

    return (buildHelper.build(parseTree.subtrees.get(0)));
  }