Package com.google.minijoe.compiler.ast

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


    Expression left = parseConditionalExpression(inFlag);

    // assignment expressions are right associative
    if (nextToken == Token.OPERATOR_ASSIGNMENT) {
      readToken();
      return new AssignmentExpression(left, parseAssignmentExpression(inFlag));
    } else if (nextToken == Token.OPERATOR_ASSIGNMENT
            || nextToken == Token.OPERATOR_MULTIPLYASSIGNMENT
            || nextToken == Token.OPERATOR_DIVIDEASSIGNMENT
            || nextToken == Token.OPERATOR_MODULOASSIGNMENT
            || nextToken == Token.OPERATOR_PLUSASSIGNMENT
View Full Code Here


    if (variableVector != null) {
      addVariable(identifier);
    }

    if (initializer != null) {
      result = new AssignmentExpression(identifier, initializer);
    } else {
      result = identifier;
    }

    return result;
View Full Code Here

  }

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

  }

  public void testObjectLiteral() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentExpression(
                new Identifier("foo"),
                new ObjectLiteral(
                    new ObjectLiteralProperty[] {}
                )
            )
        ),
        "foo = {};"
    );
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentExpression(
                new Identifier("foo"),
                new ObjectLiteral(
                    new ObjectLiteralProperty[] {
                        new ObjectLiteralProperty(
                            new StringLiteral("name"),
                            new StringLiteral("wibble")
                        )
                    }
                )
            )
        ),
        "foo = {name: \"wibble\"};"
    );
    assertParserOutput(
        new ExpressionStatement(
            new AssignmentExpression(
                new Identifier("foo"),
                new ObjectLiteral(
                    new ObjectLiteralProperty[] {
                        new ObjectLiteralProperty(
                            new StringLiteral("name"),
View Full Code Here

    );
    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

        ),
        "for (; x < 4; x++);"
    );
    assertParserOutput(
        new ForStatement(
            new AssignmentExpression(
                new Identifier("x"),
                new NumberLiteral(0.0)
            ),
            new BinaryOperatorExpression(
                new Identifier("x"),
View Full Code Here

                            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.AssignmentExpression

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.