Package com.google.minijoe.compiler.ast

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


  private Statement parseFunctionDeclaration() throws CompilerException {
    return new FunctionDeclaration(parseFunctionLiteral(true));
  }

  public Statement parseStatement() throws CompilerException {
    Statement statement;
    int lineNumber;

    if (Config.LINENUMBER) {
      lineNumber = getLineNumber();
    }

    if (nextToken == Token.OPERATOR_SEMICOLON) {
      readToken(Token.OPERATOR_SEMICOLON);
      statement = new EmptyStatement();

    } else if (nextToken == Token.OPERATOR_OPENBRACE) {
      statement = parseBlockStatement();

    } else if (nextToken == Token.KEYWORD_BREAK) {
      statement = parseBreakStatement();

    } else if (nextToken == Token.KEYWORD_CONTINUE) {
      statement = parseContinueStatement();

    } else if (nextToken == Token.KEYWORD_DO) {
      statement = parseDoStatement();

    } else if (nextToken == Token.KEYWORD_FOR) {
      statement = parseForStatement();

    } else if (nextToken == Token.KEYWORD_IF) {
      statement = parseIfStatement();

    } else if (nextToken == Token.KEYWORD_RETURN) {
      statement = parseReturnStatement();

    } else if (nextToken == Token.KEYWORD_THROW) {
      statement = parseThrowStatement();

    } else if (nextToken == Token.KEYWORD_TRY) {
      statement = parseTryStatement();

    } else if (nextToken == Token.KEYWORD_SWITCH) {
      statement = parseSwitchStatement();

    } else if (nextToken == Token.KEYWORD_VAR) {
      statement = parseVariableStatement();

    } else if (nextToken == Token.KEYWORD_WHILE) {
      statement = parseWhileStatement();

    } else if (nextToken == Token.KEYWORD_WITH) {
      statement = parseWithStatement();

    } else {
      statement = parseExpressionStatement();

    }

    if (Config.LINENUMBER) {
      statement.setLineNumber(lineNumber);
    }

    return statement;
  }
View Full Code Here


    return new ContinueStatement(identifier);
  }

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

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

    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
    // for ( var VariableDeclarationListNoIn; 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);
    expression = parseExpression(true);
    readToken(Token.OPERATOR_CLOSEPAREN);
View Full Code Here

    return new ThrowStatement(parseExpression(true));
  }

  private Statement parseTryStatement() throws CompilerException {
    Statement tryBlock = null;
    Identifier catchIdentifier = null;
    Statement catchBlock = null;
    Statement finallyBlock = null;

    readToken(Token.KEYWORD_TRY);
    tryBlock = parseBlockStatement();

    if (nextToken != Token.KEYWORD_CATCH && nextToken != Token.KEYWORD_FINALLY) {
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);
View Full Code Here

  }

  public Statement visit(DoStatement statement) throws CompilerException {
    addLineNumber(statement);

    Statement saveBreakStatement = currentBreakStatement;
    Statement saveContinueStatement = currentContinueStatement;
    currentBreakStatement = statement;
    currentContinueStatement = statement;

    setLabel(statement, "do");
View Full Code Here

  }

  public Statement visit(ForInStatement statement) throws CompilerException {
    addLineNumber(statement);

    Statement saveBreakStatement = currentBreakStatement;
    Statement saveContinueStatement = currentContinueStatement;

    currentBreakStatement = statement;
    currentContinueStatement = statement;

    statement.expression.visitExpression(this);
View Full Code Here

      if (!(statement.initial instanceof VariableExpression)) {
        writeOp(JsFunction.OP_DROP);
      }
    }

    Statement saveBreakStatement = currentBreakStatement;
    Statement saveContinueStatement = currentContinueStatement;

    currentBreakStatement = statement;
    currentContinueStatement = statement;

    setLabel(statement, "start");
View Full Code Here

  public Statement visit(SwitchStatement statement) throws CompilerException {
    addLineNumber(statement);

    statement.expression.visitExpression(this);

    Statement saveBreakStatemet = currentBreakStatement;
    currentBreakStatement = statement;

    String defaultLabel = "break";

    for (int i = 0; i < statement.clauses.length; i++) {
View Full Code Here

TOP

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

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.