Package com.google.minijoe.compiler.ast

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


        "{};"
    );
    assertParserOutput(
        new BlockStatement(
            new Statement[] {
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("foo"),
                        new NumberLiteral(1.0)
                    )
                )
            }
        ),
        "{foo = 1.0;};"
    );
    assertParserOutput(
        new BlockStatement(
            new Statement[] {
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("foo"),
                        new NumberLiteral(1.0)
                    )
                ),
                new ExpressionStatement(
                    new AssignmentExpression(
                        new Identifier("bar"),
                        new NumberLiteral(2.0)
                    )
                )
View Full Code Here


            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              )
            }
        ),
        "switch (something) {default: foo;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {default: foo; case 0: bar; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              )
            }
        ),
        "switch (something) {case 0: bar; default: foo; case 1: baz;}"
    );
    assertParserOutput(
        new SwitchStatement(
            new Identifier("something"),
            new CaseStatement[] {
              new CaseStatement(
                  new NumberLiteral(0),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("bar")
                    )
                  }
              ),
              new CaseStatement(
                  new NumberLiteral(1),
                  new Statement[] {
                    new ExpressionStatement(
                        new Identifier("baz")
                    )
                  }
              ),
              new CaseStatement(
                  null,
                  new Statement[] {
                      new ExpressionStatement(
                          new Identifier("foo")
                      )
                  }
              )
            }
View Full Code Here

    super(name);
  }

  public void testPropertyExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new PropertyExpression(
                new Identifier("foo"),
                new StringLiteral("bar")
            )
        ),
        "foo.bar;"
    );
    assertParserOutput(
        new ExpressionStatement(
            new PropertyExpression(
                new Identifier("foo"),
                new StringLiteral("bar")
            )
        ),
View Full Code Here

    );
  }

  public void testNewExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new NewExpression(
                new Identifier("Object"),
                new Expression[] {
                }
            )
        ),
        "new Object();"
    );
    assertParserOutput(
        new ExpressionStatement(
            new NewExpression(
                new Identifier("Object"),
                new Expression[] {
                  new NumberLiteral(1.0)
                }
            )
        ),
        "new Object(1.0);"
    );
    assertParserOutput(
        new ExpressionStatement(
            new NewExpression(
                new Identifier("Object"),
                new Expression[] {
                  new NumberLiteral(1.0),
                  new StringLiteral("hatstand")
View Full Code Here

    );
  }

  public void testCallExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new CallExpression(
                new Identifier("thing"),
                new Expression[] {
                }
            )
        ),
        "thing();"
    );
    assertParserOutput(
        new ExpressionStatement(
            new CallExpression(
                new Identifier("thing"),
                new Expression[] {
                  new NumberLiteral(1.0)
                }
            )
        ),
        "thing(1.0);"
    );
    assertParserOutput(
        new ExpressionStatement(
            new CallExpression(
                new Identifier("thing"),
                new Expression[] {
                  new NumberLiteral(1.0),
                  new StringLiteral("hatstand")
View Full Code Here

    super(name);
  }

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

    super(name);
  }

  public void testCommaExpression() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new BinaryOperatorExpression(
                new BinaryOperatorExpression(
                    new BinaryOperatorExpression(
                        new BinaryOperatorExpression(
                            new Identifier("foo"),
View Full Code Here

    super(name);
  }

  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
                ),
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
                ),
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.