Package com.google.minijoe.compiler.ast

Examples of com.google.minijoe.compiler.ast.Program


  public static void compile(String input, OutputStream os) throws CompilerException, IOException {
    Lexer lexer = new Lexer(input);
    Parser parser = new Parser(lexer);

    Program program = parser.parseProgram();

    if (Config.DEBUG_SOURCE) {
      Writer w = new OutputStreamWriter(System.out);
      new RoundtripVisitor(w).visit(program);
      w.flush();
View Full Code Here


    while (nextToken != Token.EOF) {
      statementVector.addElement(parseSourceElement());
    }

    return new Program(Util.vectorToStatementArray(statementVector));
  }
View Full Code Here

  }

  public void assertParserOutput(Program expected, String input) throws CompilerException {
    Lexer lexer = new Lexer(input);
    Parser parser = new Parser(lexer);
    Program program = parser.parseProgram();

    try {
      // ensure the RoundTripVisitor doesn't complain about this parse tree
      program.visitProgram(
          new RoundtripVisitor(
              new OutputStreamWriter(
                  new ByteArrayOutputStream()
              )
          )
View Full Code Here

    //   { 1 ;
    //     2 ; } 3 ;
    //

    assertParserOutput(
        new Program(
            new Statement[] {
                new BlockStatement(
                    new Statement[] {
                        new ExpressionStatement(
                            new NumberLiteral(1.0)
                        ),
                        new ExpressionStatement(
                            new NumberLiteral(2.0)
                        )
                    }
                ),
                new ExpressionStatement(
                    new NumberLiteral(3.0)
                )
            }
        ),
        "{ 1 \n 2 } 3 "
    );
    assertParserOutput(
        new Program(
            new Statement[] {
                new VariableStatement(
                    new VariableDeclaration[] {
                        new VariableDeclaration(
                            new Identifier("foo"),
View Full Code Here

TOP

Related Classes of com.google.minijoe.compiler.ast.Program

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.