You are here

protected function AbstractLexer::scan in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_annotation_discovery/lib/Doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php \Doctrine\Common\Lexer\AbstractLexer::scan()

Scans the input string for tokens.

Parameters

string $input a query string:

1 call to AbstractLexer::scan()
AbstractLexer::setInput in modules/providers/service_container_annotation_discovery/lib/Doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php
Sets the input data to be tokenized.

File

modules/providers/service_container_annotation_discovery/lib/Doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php, line 199

Class

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

Namespace

Doctrine\Common\Lexer

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],
    );
  }
}