[ExpressionLanguage] Fixed conflict between punctation and range
This commit is contained in:
parent
4e9332b6b6
commit
b521dc5ace
@ -63,10 +63,6 @@ class Lexer
|
||||
throw new SyntaxError(sprintf('Unclosed "%s"', $expect), $cur);
|
||||
}
|
||||
|
||||
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
|
||||
++$cursor;
|
||||
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
|
||||
// punctuation
|
||||
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
|
||||
++$cursor;
|
||||
} elseif (preg_match('/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
|
||||
@ -77,6 +73,10 @@ class Lexer
|
||||
// operators
|
||||
$tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1);
|
||||
$cursor += strlen($match[0]);
|
||||
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
|
||||
// punctuation
|
||||
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
|
||||
++$cursor;
|
||||
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, null, $cursor)) {
|
||||
// names
|
||||
$tokens[] = new Token(Token::NAME_TYPE, $match[0], $cursor + 1);
|
||||
|
@ -70,6 +70,10 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
'(3 + 5) ~ foo("bar").baz[4]',
|
||||
),
|
||||
array(
|
||||
array(new Token('operator', '..', 1)),
|
||||
'..',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user