protected function Lexer::scan

Scans the input string for tokens.

Parameters

string $input a query string:

1 call to Lexer::scan()
Lexer::setInput in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php
Sets the input data to be tokenized.

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Lexer.php, line 200

Class

Lexer
Base class for writing simple lexers, i.e. for creating small DSLs.

Namespace

Doctrine\Common

Code

protected function scan($input) {
  static $regex;
  if (!isset($regex)) {
    $regex = '/(' . implode(')|(', $this
      ->getCatchablePatterns()) . ')|' . implode('|', $this
      ->getNonCatchablePatterns()) . '/i';
  }
  $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
  $matches = preg_split($regex, $input, -1, $flags);
  foreach ($matches as $match) {

    // Must remain before 'value' assignment since it can change content
    $type = $this
      ->getType($match[0]);
    $this->tokens[] = array(
      'value' => $match[0],
      'type' => $type,
      'position' => $match[1],
    );
  }
}