Author: Dan Ungureanu (udan1107@gmail.com)
Inheritance: extends SqlParser\Component
 /**
  * @param Parser     $parser The instance that requests parsing.
  * @param TokensList $list   The list of tokens to be parsed.
  *
  * @return void
  */
 public function parse(Parser $parser, TokensList $list)
 {
     ++$list->idx;
     // Skipping `ALTER`.
     $this->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
     // Skipping `TABLE`.
     $list->getNextOfTypeAndValue(Token::TYPE_KEYWORD, 'TABLE');
     // Parsing affected table.
     $this->table = Expression::parse($parser, $list, array('noAlias' => true, 'noBrackets' => true));
     ++$list->idx;
     // Skipping field.
     /**
      * The state of the parser.
      *
      * Below are the states of the parser.
      *
      *      0 -----------------[ alter operation ]-----------------> 1
      *
      *      1 -------------------------[ , ]-----------------------> 0
      *
      * @var int $state
      */
     $state = 0;
     for (; $list->idx < $list->count; ++$list->idx) {
         /**
          * Token parsed at this moment.
          *
          * @var Token $token
          */
         $token = $list->tokens[$list->idx];
         // End of statement.
         if ($token->type === Token::TYPE_DELIMITER) {
             break;
         }
         // Skipping whitespaces and comments.
         if ($token->type === Token::TYPE_WHITESPACE || $token->type === Token::TYPE_COMMENT) {
             continue;
         }
         if ($state === 0) {
             $this->altered[] = AlterOperation::parse($parser, $list);
             $state = 1;
         } elseif ($state === 1) {
             if ($token->type === Token::TYPE_OPERATOR && $token->value === ',') {
                 $state = 0;
             }
         }
     }
 }
 /**
  * @param Parser     $parser The instance that requests parsing.
  * @param TokensList $list   The list of tokens to be parsed.
  *
  * @return void
  */
 public function parse(Parser $parser, TokensList $list)
 {
     ++$list->idx;
     // Skipping `ALTER`.
     $this->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
     ++$list->idx;
     // Parsing affected table.
     $this->table = Expression::parse($parser, $list, array('parseField' => 'table', 'breakOnAlias' => true));
     ++$list->idx;
     // Skipping field.
     /**
      * The state of the parser.
      *
      * Below are the states of the parser.
      *
      *      0 -----------------[ alter operation ]-----------------> 1
      *
      *      1 -------------------------[ , ]-----------------------> 0
      *
      * @var int $state
      */
     $state = 0;
     for (; $list->idx < $list->count; ++$list->idx) {
         /**
          * Token parsed at this moment.
          *
          * @var Token $token
          */
         $token = $list->tokens[$list->idx];
         // End of statement.
         if ($token->type === Token::TYPE_DELIMITER) {
             break;
         }
         // Skipping whitespaces and comments.
         if ($token->type === Token::TYPE_WHITESPACE || $token->type === Token::TYPE_COMMENT) {
             continue;
         }
         if ($state === 0) {
             $options = array();
             if ($this->options->has('DATABASE')) {
                 $options = AlterOperation::$DB_OPTIONS;
             } elseif ($this->options->has('TABLE')) {
                 $options = AlterOperation::$TABLE_OPTIONS;
             } elseif ($this->options->has('VIEW')) {
                 $options = AlterOperation::$VIEW_OPTIONS;
             }
             $this->altered[] = AlterOperation::parse($parser, $list, $options);
             $state = 1;
         } elseif ($state === 1) {
             if ($token->type === Token::TYPE_OPERATOR && $token->value === ',') {
                 $state = 0;
             }
         }
     }
 }