Package com.google.minijoe.compiler.ast

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


      vector.addElement(parseStatement());
    }

    readToken(Token.OPERATOR_CLOSEBRACE);

    return new BlockStatement(Util.vectorToStatementArray(vector));
  }
View Full Code Here


    if (statements.size() == 0) {
      return new EmptyStatement();
    } else if (statements.size() == 1) {
      return (ExpressionStatement) statements.elementAt(0);
    } else {
      return new BlockStatement(Util.vectorToStatementArray(statements));
    }
  }
View Full Code Here

  }

  public void testTryCatchStatement() throws CompilerException {
    assertParserOutput(
        new TryStatement(
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
            ),
            new Identifier("foo"),
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                }
            ),
            null
        ),
        "try {something;} catch (foo) {bar;}"
    );
    assertParserOutput(
        new TryStatement(
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
            ),
            null,
            null,
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                }
            )
        ),
        "try {something;} finally {baz;}"
    );
    assertParserOutput(
        new TryStatement(
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
            ),
            new Identifier("foo"),
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                }
            ),
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                }
View Full Code Here

        "with (foo) something;"
    );
    assertParserOutput(
        new WithStatement(
            new Identifier("foo"),
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
View Full Code Here

        ),
        "do something; while (true);"
    );
    assertParserOutput(
        new DoStatement(
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
View Full Code Here

    super(name);
  }

  public void testBlockStatement() throws CompilerException {
    assertParserOutput(
        new BlockStatement(
            new Statement[] {}
        ),
        "{};"
    );
    assertParserOutput(
        new BlockStatement(
            new Statement[] {
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("foo"),
                        new NumberLiteral(1.0)
                    )
                )
            }
        ),
        "{foo = 1.0;};"
    );
    assertParserOutput(
        new BlockStatement(
            new Statement[] {
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("foo"),
                        new NumberLiteral(1.0)
View Full Code Here

        new EmptyStatement(
        ),
        ";"
    );
    assertParserOutput(
        new BlockStatement(
            new Statement[] {
                new EmptyStatement()
            }
        ),
        "{;}"
View Full Code Here

            new Identifier("foo"),
            new LabelledStatement(
                new Identifier("bar"),
                new WhileStatement(
                    new BooleanLiteral(true),
                    new BlockStatement(
                        new Statement[] {
                            new ExpressionStatement(
                                new Identifier("baz")
                            )
                        }
View Full Code Here

    //

    assertParserOutput(
        new Program(
            new Statement[] {
                new BlockStatement(
                    new Statement[] {
                        new ExpressionStatement(
                            new NumberLiteral(1.0)
                        ),
                        new ExpressionStatement(
View Full Code Here

        "while (true) something;"
    );
    assertParserOutput(
        new WhileStatement(
            new BooleanLiteral(true),
            new BlockStatement(
                new Statement[] {
                    new ExpressionStatement(
                        new Identifier("something")
                    )
                }
View Full Code Here

TOP

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

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.