Package com.google.minijoe.compiler.ast

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


  public void testLogicalNotExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new UnaryOperatorExpression(
                new Identifier("foo"),
                Token.OPERATOR_LOGICALNOT
            )
        ),
        "!foo;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new UnaryOperatorExpression(
                new UnaryOperatorExpression(
                    new Identifier("foo"),
                    Token.OPERATOR_LOGICALNOT
                ),
                Token.OPERATOR_LOGICALNOT
            )
        ),
View Full Code Here


  public void testFunctionDeclaration() throws CompilerException {
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "function foo() {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a) {}"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                  new Identifier("b"),
                  new Identifier("c"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a, b, c) {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("a"),
                new Identifier[] {
                },
                new Statement[] {
                  new FunctionDeclaration(
                      new FunctionLiteral(
                          new Identifier("b"),
                          new Identifier[] {
                          },
                          new Statement[] {
                            new IfStatement(
                                new NumberLiteral(0.0),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        new Identifier("c"),
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
                                    )
View Full Code Here

  }

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

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

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

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

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

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

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

  public void testShiftLeftAssignmentExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_SHIFTLEFTASSIGNMENT
            )
        ),
        "foo <<= bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentOperatorExpression(
                new Identifier("foo"),
                new AssignmentOperatorExpression(
                    new Identifier("bar"),
                    new Identifier("baz"),
                    Token.OPERATOR_SHIFTLEFTASSIGNMENT
                ),
                Token.OPERATOR_SHIFTLEFTASSIGNMENT
            )
        ),
        "foo <<= bar <<= baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
                    Token.OPERATOR_PLUS
                ),
                Token.OPERATOR_SHIFTLEFTASSIGNMENT
            )
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.