Skip to content

Commit

Permalink
Merge pull request #6 from odolbeau/feat-modifiers
Browse files Browse the repository at this point in the history
Add a way to override modifiers
  • Loading branch information
guilhermeblanco committed Jun 11, 2014
2 parents f12a5f7 + 51af164 commit db77c80
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/Doctrine/Common/Lexer/AbstractLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@ protected function scan($input)
static $regex;

if ( ! isset($regex)) {
$regex = '/(' . implode(')|(', $this->getCatchablePatterns()) . ')|'
. implode('|', $this->getNonCatchablePatterns()) . '/i';
$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;
Expand Down Expand Up @@ -288,6 +292,16 @@ public function getLiteral($token)
return $token;
}

/**
* Regex modifiers
*
* @return string
*/
protected function getModifiers()
{
return 'i';
}

/**
* Lexical catchable patterns.
*
Expand Down

0 comments on commit db77c80

Please sign in to comment.