/**
  * {@inheritdoc}
  */
 protected function call(Lexer $lexer)
 {
     while (true) {
         $peek = $lexer->peek();
         //file_put_contents(__DIR__ . '/foo.log', '#' . $lexer->pos() . ' ' . $peek . ' (' . $lexer->getTokenValue() . ')' . PHP_EOL, FILE_APPEND);
         if ($peek === null) {
             $lexer->emit(new EOFToken());
             return;
         }
         if ('.' === $peek) {
             $lexer->next();
             $lexer->emit(new PeriodToken());
             continue;
         }
         if ('?' === $peek) {
             $lexer->next();
             $lexer->emit(new QuestionMarkToken());
             continue;
         }
         if ('!' === $peek) {
             $lexer->next();
             $lexer->emit(new ExclamationPointToken());
             continue;
         }
         if (in_array($peek, QuotedStringState::CHARS, true)) {
             return new QuotedStringState();
         }
         if (in_array($peek, WhitespaceState::CHARS, true)) {
             return new WhitespaceState();
         }
         return new WordState();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function call(Lexer $lexer)
 {
     $nonWordChars = $this->getNonWordChars();
     while (!in_array($lexer->peek(), $nonWordChars, true)) {
         $lexer->next();
     }
     $value = $lexer->getTokenValue();
     $firstChar = substr($value, 0, 1);
     if (ctype_upper($firstChar)) {
         $lexer->emit(new CapitalizedWordToken());
     } else {
         $lexer->emit(new WordToken());
     }
     return new TextState();
 }
 /**
  * {@inheritdoc}
  */
 protected function call(Lexer $lexer)
 {
     while (in_array($lexer->peek(), self::CHARS, true)) {
         $lexer->next();
     }
     $lexer->emit(new WhitespaceToken());
     return new TextState();
 }
 /**
  * {@inheritdoc}
  */
 protected function call(Lexer $lexer)
 {
     $start = $lexer->next();
     while (true) {
         $next = $lexer->next();
         if ($next === null) {
             throw new StateException('Failed to find end of quote. Reached end of input. Read: ' . $lexer->getTokenValue());
         }
         if ($start === $next) {
             break;
         }
     }
     $lexer->emit(new QuotedStringToken());
     return new TextState();
 }