Skip to content

Commit 4d9c25d

Browse files
author
Kirill Nesmeyanov
committed
Fix lexemes priority and optimize conditional expressions
1 parent 8aea70f commit 4d9c25d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

resources/grammar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
'T_BOOL_LITERAL' => '(?i)(?:true|false)(?![a-zA-Z0-9\\-_\\x80-\\xff])',
2222
'T_NULL_LITERAL' => '(?i)(?:null)(?![a-zA-Z0-9\\-_\\x80-\\xff])',
2323
'T_THIS' => '\\$this(?![a-zA-Z0-9\\-_\\x80-\\xff])',
24-
'T_EQ' => '(?i)is(?![a-zA-Z0-9\\-_\\x80-\\xff])',
2524
'T_NEQ' => '(?i)is\\h+not(?![a-zA-Z0-9\\-_\\x80-\\xff])',
25+
'T_EQ' => '(?i)is(?![a-zA-Z0-9\\-_\\x80-\\xff])',
2626
'T_VARIABLE' => '\\$[a-zA-Z_\\x80-\\xff][a-zA-Z0-9\\-_\\x80-\\xff]*',
2727
'T_NAME' => '[a-zA-Z_\\x80-\\xff][a-zA-Z0-9\\-_\\x80-\\xff]*',
2828
'T_ANGLE_BRACKET_OPEN' => '<',
@@ -175,7 +175,7 @@
175175
113 => new \Phplrt\Parser\Grammar\Lexeme('T_EQ', true),
176176
114 => new \Phplrt\Parser\Grammar\Lexeme('T_NEQ', true),
177177
115 => new \Phplrt\Parser\Grammar\Alternation([113, 114]),
178-
116 => new \Phplrt\Parser\Grammar\Alternation(['Type', 26]),
178+
116 => new \Phplrt\Parser\Grammar\Alternation([26, 'Type']),
179179
117 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', false),
180180
118 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
181181
119 => new \Phplrt\Parser\Grammar\Concatenation([112]),

resources/grammar/lexemes.pp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// Identifier
1717

1818
%token T_THIS \$this(?![a-zA-Z0-9\-_\x80-\xff])
19-
%token T_EQ (?i)is(?![a-zA-Z0-9\-_\x80-\xff])
2019
%token T_NEQ (?i)is\h+not(?![a-zA-Z0-9\-_\x80-\xff])
20+
%token T_EQ (?i)is(?![a-zA-Z0-9\-_\x80-\xff])
2121
%token T_VARIABLE \$[a-zA-Z_\x80-\xff][a-zA-Z0-9\-_\x80-\xff]*
2222
%token T_NAME [a-zA-Z_\x80-\xff][a-zA-Z0-9\-_\x80-\xff]*
2323

resources/grammar/ternary.pp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ OptionalTernaryExpressionSuffix
4141
;
4242

4343
TernaryExpressionSuffix
44-
: (<T_EQ>|<T_NEQ>) (Type()|VariableLiteral())
44+
: (<T_EQ>|<T_NEQ>) (VariableLiteral()|Type())
4545
::T_QMARK:: Type()
4646
::T_COLON:: Type()
4747
;

0 commit comments

Comments
 (0)