Package com.google.minijoe.compiler.ast

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


        expression = new PropertyExpression(expression, property);
      } else if (nextToken == Token.OPERATOR_DOT) {
        // transform x.bar to x["bar"]
        readToken(Token.OPERATOR_DOT);
        Identifier identifier = parseIdentifier();
        expression = new PropertyExpression(expression, new StringLiteral(identifier.string));
      } else {
        return expression;
      }
    }
  }
View Full Code Here


  private ObjectLiteralProperty parseObjectLiteralProperty() throws CompilerException {
    Expression propertyName = null;
    Expression propertyValue = null;

    if (nextToken.isIdentifier()) {
      propertyName = new StringLiteral(parseIdentifier().string);
    } else if (nextToken.isStringLiteral()) {
      propertyName = parseStringLiteral();
    } else if (nextToken.isNumericLiteral()) {
      propertyName = parseNumericLiteral();
    } else {
View Full Code Here

      throwCompilerException("string literal expected");
    }

    readToken();

    return new StringLiteral(string);
  }
View Full Code Here

  }

  public void testStringLiteral() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new StringLiteral("foo")
        ),
        "\"foo\";"
    );
    assertParserOutput(
        new ExpressionStatement(
            new StringLiteral("bar")
        ),
        "\'bar\';"
    );
  }
View Full Code Here

            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"),
                            new StringLiteral("wibble")
                        ),
                        new ObjectLiteralProperty(
                            new StringLiteral("value"),
                            new NumberLiteral(1.0)
                        )
                    }
                )
            )
View Full Code Here

    );
    assertParserOutput(
        new ForInStatement(
            new PropertyExpression(
                new Identifier("foo"),
                new StringLiteral("bar")
            ),
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(1.0),
                    new NumberLiteral(2.0),
View Full Code Here

    assertParserOutput(
        new ExpressionStatement(
            new IncrementExpression(
                new PropertyExpression(
                    new Identifier("foo"),
                    new StringLiteral("bar")
                ),
                1,
                true
            )
        ),
View Full Code Here

    assertParserOutput(
        new ExpressionStatement(
            new IncrementExpression(
                new PropertyExpression(
                    new Identifier("foo"),
                    new StringLiteral("bar")
                ),
                -1,
                true
            )
        ),
View Full Code Here

  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")
            )
        ),
        "foo[\"bar\"];"
    );
  }
View Full Code Here

        new ExpressionStatement(
            new NewExpression(
                new Identifier("Object"),
                new Expression[] {
                  new NumberLiteral(1.0),
                  new StringLiteral("hatstand")
                }
            )
        ),
        "new Object(1.0, 'hatstand');"
    );
View Full Code Here

TOP

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

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.