Package com.google.minijoe.compiler.ast

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


      readToken(Token.KEYWORD_NULL);
      return new NullLiteral();

    } else if (nextToken == Token.KEYWORD_TRUE) {
      readToken(Token.KEYWORD_TRUE);
      return new BooleanLiteral(true);

    } else if (nextToken == Token.KEYWORD_FALSE) {
      readToken(Token.KEYWORD_FALSE);
      return new BooleanLiteral(false);

    } else if (nextToken == Token.OPERATOR_OPENPAREN) {
      readToken(Token.OPERATOR_OPENPAREN);
      Expression expression = parseExpression(true);
      readToken(Token.OPERATOR_CLOSEPAREN);
View Full Code Here


  }

  public void testIfStatement() throws CompilerException {
    assertParserOutput(
        new IfStatement(
            new BooleanLiteral(true),
            new ExpressionStatement(
                new Identifier("foo")
            ),
            null
        ),
        "if (true) foo;"
    );
    assertParserOutput(
        new IfStatement(
            new BooleanLiteral(true),
            new ExpressionStatement(
                new Identifier("foo")
            ),
            new ExpressionStatement(
                new Identifier("bar")
            )
        ),
        "if (true) foo; else bar;"
    );
    assertParserOutput(
        new IfStatement(
            new BooleanLiteral(true),
            new IfStatement(
                new BooleanLiteral(true),
                new ExpressionStatement(
                    new Identifier("foo")
                ),
                new ExpressionStatement(
                    new Identifier("bar")
                )
            ),
            null
        ),
        "if (true) if (true) foo; else bar;"
    );
    assertParserOutput(
        new IfStatement(
            new BooleanLiteral(true),
            new IfStatement(
                new BooleanLiteral(true),
                new ExpressionStatement(
                    new Identifier("foo")
                ),
                new ExpressionStatement(
                    new Identifier("bar")
View Full Code Here

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

  }

  public void testBooleanLiteral() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BooleanLiteral(true)
        ),
        "true;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BooleanLiteral(false)
        ),
        "false;"
    );
  }
View Full Code Here

  }

  public void testThrowStatement() throws CompilerException {
    assertParserOutput(
        new ThrowStatement(
            new BooleanLiteral(true)
        ),
        "throw true;"
    );
    assertParserOutput(
        new ThrowStatement(
View Full Code Here

        new LabelledStatement(
            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

        ),
        "return 0;"
    );
    assertParserOutput(
        new ReturnStatement(
            new BooleanLiteral(true)
        ),
        "return true;"
    );
  }
View Full Code Here

  }

  public void testWhileStatement() throws CompilerException {
    assertParserOutput(
        new WhileStatement(
            new BooleanLiteral(true),
            new ExpressionStatement(
                new Identifier("something")
            )
        ),
        "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.BooleanLiteral

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.