parseStatement method

Statement parseStatement()

Implementation

Statement parseStatement() {
  if (token?.type == Token.LBRACE) return parseBlock();
  if (token?.type == Token.SEMICOLON) return parseEmptyStatement();
  if (token?.type != Token.NAME) return parseExpressionStatement();

  switch (token?.value) {
    case 'var':
    case 'let':
    case 'const':
      return parseVariableDeclarationStatement();
    case 'if':
      return parseIf();
    case 'do':
      return parseDoWhile();
    case 'while':
      return parseWhile();
    case 'for':
      return parseFor();
    case 'continue':
      return parseContinue();
    case 'break':
      return parseBreak();
    case 'return':
      return parseReturn();
    case 'with':
      return parseWith();
    case 'switch':
      return parseSwitch();
    case 'throw':
      return parseThrow();
    case 'try':
      return parseTry();
    case 'debugger':
      return parseDebuggerStatement();
    case 'function':
      return parseFunctionDeclaration();
    default:
      return parseExpressionOrLabeledStatement();
  }
}