Package com.google.minijoe.compiler.ast

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


  }

  public void testBitwiseShiftRightUnsignedExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_SHIFTRIGHTUNSIGNED
            )
        ),
        "foo >>> bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_SHIFTRIGHTUNSIGNED
                ),
                new Identifier("baz"),
                Token.OPERATOR_SHIFTRIGHTUNSIGNED
            )
        ),
        "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_SHIFTRIGHTUNSIGNED
View Full Code Here


    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("bar"),
                    new BinaryOperatorExpression(
                        new Identifier("x"),
                        new Identifier("baz"),
                        Token.KEYWORD_IN
                    )
                )
            }
        ),
        "var bar = x in baz;"
    );
    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("foo"),
                    null
                ),
                new VariableDeclaration(
                    new Identifier("bar"),
                    null
                )
            }
        ),
        "var foo, bar;"
    );
    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("foo"),
                    new NumberLiteral(1.0)
                ),
                new VariableDeclaration(
                    new Identifier("bar"),
                    null
                )
            }
        ),
        "var foo = 1.0, bar;"
    );
    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("foo"),
                    new NumberLiteral(1.0)
                ),
                new VariableDeclaration(
                    new Identifier("bar"),
                    new BinaryOperatorExpression(
                        new Identifier("x"),
                        new Identifier("baz"),
                        Token.KEYWORD_IN
                    )
                )
View Full Code Here

        "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
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

  }

  public void testCommaExpression() throws CompilerException {
    assertParserOutput(
        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

  }

  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
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
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
View Full Code Here

  }

  public void testLessThanExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_LESSTHAN
            )
        ),
        "foo < bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_LESSTHAN
                ),
                new Identifier("baz"),
                Token.OPERATOR_LESSTHAN
            )
        ),
        "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_LESSTHAN
View Full Code Here

TOP

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

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.