Package com.google.minijoe.compiler.ast

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


    assertParserOutput(
        new ForStatement(
            null,
            null,
            new IncrementExpression(
                new Identifier("x"),
                +1,
                true
            ),
            new EmptyStatement()
        ),
        "for (;; x++);"
    );
    assertParserOutput(
        new ForStatement(
            null,
            new BinaryOperatorExpression(
                new Identifier("x"),
                new NumberLiteral(4.0),
                Token.OPERATOR_LESSTHAN
            ),
            null,
            new EmptyStatement()
        ),
        "for (; x < 4;);"
    );
    assertParserOutput(
        new ForStatement(
            null,
            new BinaryOperatorExpression(
                new Identifier("x"),
                new NumberLiteral(4.0),
                Token.OPERATOR_LESSTHAN
            ),
            new IncrementExpression(
                new Identifier("x"), +1, true
            ),
            new EmptyStatement()
        ),
        "for (; x < 4; x++);"
    );
    assertParserOutput(
        new ForStatement(
            new AssignmentExpression(
                new Identifier("x"),
                new NumberLiteral(0.0)
            ),
            new BinaryOperatorExpression(
                new Identifier("x"),
                new NumberLiteral(4.0),
                Token.OPERATOR_LESSTHAN
            ),
            new IncrementExpression(
                new Identifier("x"), +1, true
            ),
            new EmptyStatement()
        ),
        "for (x = 0; x < 4; x++);"
    );
    assertParserOutput(
        new ForStatement(
            new VariableExpression(
                new VariableDeclaration[] {
                    new VariableDeclaration(
                        new Identifier("x"),
                        new NumberLiteral(0.0)
                    ),
                }
            ),
            new BinaryOperatorExpression(
                new Identifier("x"),
                new NumberLiteral(4.0),
                Token.OPERATOR_LESSTHAN
            ),
            new IncrementExpression(
                new Identifier("x"), +1, true
            ),
            new EmptyStatement()
        ),
        "for (var x = 0; x < 4; x++);"
    );
    assertParserOutput(
        new ForStatement(
            new VariableExpression(
                new VariableDeclaration[] {
                    new VariableDeclaration(
                        new Identifier("x"),
                        new NumberLiteral(0.0)
                    ),
                    new VariableDeclaration(
                        new Identifier("y"),
                        new NumberLiteral(8.0)
                    )
                }
            ),
            new BinaryOperatorExpression(
                new Identifier("x"),
                new NumberLiteral(4.0),
                Token.OPERATOR_LESSTHAN
            ),
            new BinaryOperatorExpression(
                new IncrementExpression(
                    new Identifier("x"), +1, true
                ),
                new IncrementExpression(
                    new Identifier("y"), -1, true
                ),
                Token.OPERATOR_COMMA
            ),
            new EmptyStatement()
        ),
View Full Code Here


  public void testAdditionExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_PLUS
            )
        ),
        "foo + bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_PLUS
                ),
                new Identifier("baz"),
                Token.OPERATOR_PLUS
            )
        ),
        "foo + bar + baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(2.0),
                    Token.OPERATOR_MULTIPLY
                ),
                Token.OPERATOR_PLUS
            )
View Full Code Here

  public void testSubtractionExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_MINUS
            )
        ),
        "foo - bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_MINUS
                ),
                new Identifier("baz"),
                Token.OPERATOR_MINUS
            )
        ),
        "foo - bar - baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(2.0),
                    Token.OPERATOR_MULTIPLY
                ),
                Token.OPERATOR_MINUS
            )
View Full Code Here

        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new BinaryOperatorExpression(
                        new BinaryOperatorExpression(
                            new Identifier("foo"),
                            new Identifier("bar"),
                            Token.OPERATOR_MULTIPLY
                        ),
                        new BinaryOperatorExpression(
                            new Identifier("foo"),
                            new Identifier("bar"),
                            Token.OPERATOR_DIVIDE
                        ),
                        Token.OPERATOR_COMMA
                    ),
                    new BinaryOperatorExpression(
                        new Identifier("foo"),
                        new Identifier("bar"),
                        Token.OPERATOR_PLUS
                    ),
                    Token.OPERATOR_COMMA
                ),
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_MINUS
                ),
                Token.OPERATOR_COMMA
            )
        ),
View Full Code Here

        ),
        "throw true;"
    );
    assertParserOutput(
        new ThrowStatement(
            new Identifier("something")
        ),
        "throw something;"
    );
  }
View Full Code Here

  public void testMultiplyExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_MULTIPLY
            )
        ),
        "foo * bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_MULTIPLY
                ),
                new Identifier("baz"),
                Token.OPERATOR_MULTIPLY
            )
        ),
        "foo * bar * baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new IncrementExpression(
                    new Identifier("bar"), 1, false
                ),
                Token.OPERATOR_MULTIPLY
            )
        ),
        "foo * ++ bar;"
View Full Code Here

  public void testDivideExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_DIVIDE
            )
        ),
        "foo / bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_DIVIDE
                ),
                new Identifier("baz"),
                Token.OPERATOR_DIVIDE
            )
        ),
        "foo / bar / baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new IncrementExpression(
                    new Identifier("bar"), 1, false
                ),
                Token.OPERATOR_DIVIDE
            )
        ),
        "foo / ++ bar;"
View Full Code Here

  public void testModuloExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_MODULO
            )
        ),
        "foo % bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_MODULO
                ),
                new Identifier("baz"),
                Token.OPERATOR_MODULO
            )
        ),
        "foo % bar % baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new IncrementExpression(
                    new Identifier("bar"), 1, false
                ),
                Token.OPERATOR_MODULO
            )
        ),
        "foo % ++ bar;"
View Full Code Here

  }

  public void testLabelledStatement() throws CompilerException {
    assertParserOutput(
        new LabelledStatement(
            new Identifier("foo"),
            new EmptyStatement()
        ),
        "foo: ;"
    );
    assertParserOutput(
        new LabelledStatement(
            new Identifier("foo"),
            new LabelledStatement(
                new Identifier("bar"),
                new EmptyStatement()
            )
        ),
        "foo: bar: ;"
    );
    assertParserOutput(
        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

        new Program(
            new Statement[] {
                new VariableStatement(
                    new VariableDeclaration[] {
                        new VariableDeclaration(
                            new Identifier("foo"),
                            null
                        )
                    }
                ),
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("bar"),
                        new NumberLiteral(1.0)
                    )
                )
            }
        ),
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.