Package com.google.minijoe.compiler.ast

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


        ),
        "break;"
    );
    assertParserOutput(
        new BreakStatement(
            new Identifier("loop")
        ),
        "break loop;"
    );
  }
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")
                )
            ),
            new ExpressionStatement(
                new Identifier("baz")
            )
        ),
        "if (true) if (true) foo; else bar; else baz;"
    );
  }
View Full Code Here

    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")
                    )
                }
            )
        ),
        "try {something;} catch (foo) {bar;} finally {baz;}"
View Full Code Here

  public void testEqualsExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_EQUALEQUAL
            )
        ),
        "foo == bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_EQUALEQUAL
                ),
                new Identifier("baz"),
                Token.OPERATOR_EQUALEQUAL
            )
        ),
        "foo == bar == baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_EQUALEQUAL
            )
View Full Code Here

  public void testNotEqualsExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_NOTEQUAL
            )
        ),
        "foo != bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_NOTEQUAL
                ),
                new Identifier("baz"),
                Token.OPERATOR_NOTEQUAL
            )
        ),
        "foo != bar != baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_NOTEQUAL
            )
View Full Code Here

  public void testStrictEqualsExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_EQUALEQUALEQUAL
            )
        ),
        "foo === bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_EQUALEQUALEQUAL
                ),
                new Identifier("baz"),
                Token.OPERATOR_EQUALEQUALEQUAL
            )
        ),
        "foo === bar === baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_EQUALEQUALEQUAL
            )
View Full Code Here

  public void testStrictNotEqualsExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_NOTEQUALEQUAL
            )
        ),
        "foo !== bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_NOTEQUALEQUAL
                ),
                new Identifier("baz"),
                Token.OPERATOR_NOTEQUALEQUAL
            )
        ),
        "foo !== bar !== baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_NOTEQUALEQUAL
            )
View Full Code Here

  public void testBitwiseAndExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_BITWISEAND
            )
        ),
        "foo & bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_BITWISEAND
                ),
                new Identifier("baz"),
                Token.OPERATOR_BITWISEAND
            )
        ),
        "foo & bar & baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_BITWISEAND
            )
View Full Code Here

  public void testBitwiseOrExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_BITWISEOR
            )
        ),
        "foo | bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_BITWISEOR
                ),
                new Identifier("baz"),
                Token.OPERATOR_BITWISEOR
            )
        ),
        "foo | bar | baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_BITWISEOR
            )
View Full Code Here

  public void testBitwiseXorExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_BITWISEXOR
            )
        ),
        "foo ^ bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_BITWISEXOR
                ),
                new Identifier("baz"),
                Token.OPERATOR_BITWISEXOR
            )
        ),
        "foo ^ bar ^ baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_BITWISEXOR
            )
View Full Code Here

TOP

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

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.