Package com.google.minijoe.compiler.ast

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


    return new ContinueStatement(identifier);
  }

  private Statement parseDoStatement() throws CompilerException {
    Statement statement;
    Expression expression;

    readToken(Token.KEYWORD_DO);
    statement = parseStatement();
    readToken(Token.KEYWORD_WHILE);
    readToken(Token.OPERATOR_OPENPAREN);
View Full Code Here


    return new DoStatement(statement, expression);
  }

  private Statement parseExpressionStatement() throws CompilerException {
    Expression expression = parseExpression(true);

    // TODO there are comments in the v8 code about wrapping a
    // labelled try statement in a block and applying the label to the outer
    // block. we should consider doing something similar here if handling a
    // labelled try block proves problematic.
View Full Code Here

      return new ExpressionStatement(expression);
    }
  }

  private Statement parseForStatement() throws CompilerException {
    Expression declaration = null;
    Expression initial = null;
    Expression condition = null;
    Expression increment = null;
    Expression variable = null;
    Expression expression = null;
    Statement statement = null;

    // 'for' statements can be one of the follow four productions:
    //
    // for ( ExpressionNoIn_opt; Expression_opt ; Expression_opt ) Statement
View Full Code Here

    return statement;
  }

  private Statement parseIfStatement() throws CompilerException {
    Expression expression = null;
    Statement trueStatement = null;
    Statement falseStatement = null;

    readToken(Token.KEYWORD_IF);
    readToken(Token.OPERATOR_OPENPAREN);
View Full Code Here

    return new IfStatement(expression, trueStatement, falseStatement);
  }

  private Statement parseReturnStatement() throws CompilerException {
    Expression result = null;

    readToken(Token.KEYWORD_RETURN);

    if (nextToken != Token.OPERATOR_SEMICOLON) {
      result = parseExpression(true);
View Full Code Here

    Vector caseClauseVector = new Vector();
    boolean defaultSeen = false;

    readToken(Token.KEYWORD_SWITCH);
    readToken(Token.OPERATOR_OPENPAREN);
    Expression switchExpression = parseExpression(true);
    readToken(Token.OPERATOR_CLOSEPAREN);

    readToken(Token.OPERATOR_OPENBRACE);

    while (nextToken != Token.OPERATOR_CLOSEBRACE) {
      Expression caseExpression = null;
      Vector caseStatements = new Vector();

      if (nextToken == Token.KEYWORD_CASE) {
        readToken(Token.KEYWORD_CASE);
        caseExpression = parseExpression(true);
View Full Code Here

    return new VariableStatement(Util.vectorToDeclarationArray(declarationVector));
  }

  private Statement parseWhileStatement() throws CompilerException {
    Statement statement;
    Expression expression;

    readToken(Token.KEYWORD_WHILE);
    readToken(Token.OPERATOR_OPENPAREN);
    expression = parseExpression(true);
    readToken(Token.OPERATOR_CLOSEPAREN);
View Full Code Here

    return new WhileStatement(expression, statement);
  }

  private Statement parseWithStatement() throws CompilerException {
    Statement statement;
    Expression expression;

    readToken(Token.KEYWORD_WITH);
    readToken(Token.OPERATOR_OPENPAREN);
    expression = parseExpression(true);
    readToken(Token.OPERATOR_CLOSEPAREN);
View Full Code Here

  // Expressions
  //

  private VariableDeclaration parseVariableDeclaration(boolean inFlag) throws CompilerException {
    Identifier identifier = parseIdentifier();
    Expression initializer = null;

    if (nextToken == Token.OPERATOR_ASSIGNMENT) {
      readToken(Token.OPERATOR_ASSIGNMENT);
      initializer = parseAssignmentExpression(inFlag);
    }
View Full Code Here

    return new VariableDeclaration(identifier, initializer);
  }

  private Expression parseExpression(boolean inFlag) throws CompilerException {
    Expression left = parseAssignmentExpression(inFlag);

    // comma expressions are left associative
    while (true) {
      if (nextToken == Token.OPERATOR_COMMA) {
        readToken(Token.OPERATOR_COMMA);
        Expression right = parseAssignmentExpression(inFlag);
        left = new BinaryOperatorExpression(left, right, Token.OPERATOR_COMMA);
      } else {
        return left;
      }
    }
View Full Code Here

TOP

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

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.