Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Update Lexer.php #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Llk/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,35 @@ protected function nextToken($offset)
protected function matchLexeme($lexeme, $regex, $offset)
{
$_regex = str_replace('#', '\#', $regex);
$preg = preg_match(
$preg = @preg_match(
'#\G(?|' . $_regex . ')#' . $this->_pcreOptions,
$this->_text,
$matches,
0,
$offset
);

if (false === $preg) {
switch (preg_last_error()) {
case 1:
throw new Compiler\Exception\Lexer(
'The lexeme "%s" contains invalid regex "%s".',
4,
[$lexeme, $regex]
);
break;
default:
throw new Compiler\Exception\Lexer(
'An error occurred in the PHP regex engine. ' .
'Error code: %d',
5,
[preg_last_error()]
);
break;
}

}

if (0 === $preg) {
return null;
}
Expand Down