Package com.google.minijoe.compiler.ast

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


    if (nextToken == Token.OPERATOR_ASSIGNMENT) {
      readToken(Token.OPERATOR_ASSIGNMENT);
      initializer = parseAssignmentExpression(inFlag);
    }

    return new VariableDeclaration(identifier, initializer);
  }
View Full Code Here


  public void testVariableStatement() throws CompilerException {
    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("foo"),
                    null
                )
            }
        ),
        "var foo;"
    );
    assertParserOutput(
        new VariableStatement(
            new VariableDeclaration[] {
                new VariableDeclaration(
                    new Identifier("foo"),
                    new NumberLiteral(1.0)
                )
            }
        ),
        "var foo = 1.0;"
    );
    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 (foo.bar in [1, 2, 3, 4]);"
    );
    assertParserOutput(
        new ForInStatement(
            new VariableDeclaration(
                new Identifier("foo"),
                null
            ),
            new ArrayLiteral(
                new Expression[] {
View Full Code Here

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

    assertParserOutput(
        new Program(
            new Statement[] {
                new VariableStatement(
                    new VariableDeclaration[] {
                        new VariableDeclaration(
                            new Identifier("foo"),
                            null
                        )
                    }
                ),
View Full Code Here

                    new Identifier("c"),
                },
                new Statement[] {
                    new VariableStatement(
                        new VariableDeclaration[] {
                            new VariableDeclaration(
                                new Identifier("bar"),
                                new NumberLiteral(0.0)
                            )
                        }
                    )
View Full Code Here

TOP

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

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.