function AbstractLexer::scan
Scans the input string for tokens.
Parameters
string $input A query string.:
Return value
void
1 call to AbstractLexer::scan()
- AbstractLexer::setInput in vendor/
doctrine/ lexer/ src/ AbstractLexer.php - Sets the input data to be tokenized.
File
-
vendor/
doctrine/ lexer/ src/ AbstractLexer.php, line 249
Class
- AbstractLexer
- Base class for writing simple lexers, i.e. for creating small DSLs.
Namespace
Doctrine\Common\LexerCode
protected function scan($input) {
if (!isset($this->regex)) {
$this->regex = sprintf('/(%s)|%s/%s', implode(')|(', $this->getCatchablePatterns()), implode('|', $this->getNonCatchablePatterns()), $this->getModifiers());
}
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
$matches = preg_split($this->regex, $input, -1, $flags);
if ($matches === false) {
// Work around https://bugs.php.net/78122
$matches = [
[
$input,
0,
],
];
}
foreach ($matches as $match) {
// Must remain before 'value' assignment since it can change content
$firstMatch = $match[0];
$type = $this->getType($firstMatch);
$this->tokens[] = new Token($firstMatch, $type, $match[1]);
}
}