Package com.google.minijoe.compiler.ast

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


    );
  }

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


                new Identifier("bar"),
                new WhileStatement(
                    new BooleanLiteral(true),
                    new BlockStatement(
                        new Statement[] {
                            new ExpressionStatement(
                                new Identifier("baz")
                            )
                        }
                    )
                )
View Full Code Here

    assertParserOutput(
        new Program(
            new Statement[] {
                new BlockStatement(
                    new Statement[] {
                        new ExpressionStatement(
                            new NumberLiteral(1.0)
                        ),
                        new ExpressionStatement(
                            new NumberLiteral(2.0)
                        )
                    }
                ),
                new ExpressionStatement(
                    new NumberLiteral(3.0)
                )
            }
        ),
        "{ 1 \n 2 } 3 "
    );
    assertParserOutput(
        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

                          new Identifier[] {
                          },
                          new Statement[] {
                            new IfStatement(
                                new NumberLiteral(0.0),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        new Identifier("c"),
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
                                    )
                                ),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        null,
                                        new Identifier[] {
                                        },
                                        new Statement[] {
View Full Code Here

    super(name);
  }

  public void testExpressionStatement() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new PropertyExpression(
                new NewExpression(
                    new PropertyExpression(
                        new NewExpression(
                            new Identifier("foo"),
View Full Code Here

    // we're need to put the function literals in parenthesis to ensure that
    // they're parsed as function expressions and not function declarations.

    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                null,
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function () {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function foo() {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "(function foo(a) {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            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 ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                    new Identifier("a"),
                    new Identifier("b"),
View Full Code Here

    super(name);
  }

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

    );
  }

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

    );
  }

  public void testGreaterThanExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new Identifier("bar"),
                Token.OPERATOR_GREATERTHAN
            )
        ),
        "foo > bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new Identifier("foo"),
                    new Identifier("bar"),
                    Token.OPERATOR_GREATERTHAN
                ),
                new Identifier("baz"),
                Token.OPERATOR_GREATERTHAN
            )
        ),
        "foo > bar > baz;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new Identifier("foo"),
                new BinaryOperatorExpression(
                    new Identifier("bar"),
                    new NumberLiteral(1.0),
View Full Code Here

    );
  }

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

TOP

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

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.