/** * {@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) { $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(); }