Skip to content

Commit abf8733

Browse files
author
Kirill Nesmeyanov
committed
Add "$this" variable reference as single expression and add basic conditional gte/lte/gt/lt tokens
1 parent 0721ccf commit abf8733

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

resources/grammar.pp2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ TypesList -> {
140140

141141
PrimaryType
142142
: ::T_PARENTHESIS_OPEN:: Type() ::T_PARENTHESIS_CLOSE::
143+
| ThisLiteral()
143144
| Literal()
144145
| CallableType()
145146
| NamedType()

resources/grammar/callable.pp2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ OptionalCallableParameter -> {
4646

4747
NamedCallableParameter -> {
4848
if (\count($children) === 1) {
49+
4950
return $children[0];
5051
}
5152

resources/grammar/lexemes.pp2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
%token T_NEQ (?i)is\h+not(?![a-zA-Z0-9\-_\x80-\xff])
1919
%token T_EQ (?i)is(?![a-zA-Z0-9\-_\x80-\xff])
20+
%token T_THIS \$this\b
2021
%token T_VARIABLE \$[a-zA-Z_\x80-\xff][a-zA-Z0-9\-_\x80-\xff]*
2122
%token T_NAME_WITH_SPACE [a-zA-Z_\x80-\xff][a-zA-Z0-9\-_\x80-\xff]*\s+?
2223
%token T_NAME [a-zA-Z_\x80-\xff][a-zA-Z0-9\-_\x80-\xff]*
2324

2425
// Special Chars
2526

27+
%token T_LTE <=
28+
%token T_GTE >=
2629
%token T_ANGLE_BRACKET_OPEN <
2730
%token T_ANGLE_BRACKET_CLOSE >
2831
%token T_PARENTHESIS_OPEN \(

resources/grammar/literals.pp2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ VariableLiteral -> {
2222
return Node\Literal\VariableLiteralNode::parse($token->getValue());
2323
}
2424
: <T_VARIABLE>
25+
| <T_THIS>
26+
;
27+
28+
ThisLiteral -> {
29+
return Node\Literal\VariableLiteralNode::parse($token->getValue());
30+
}
31+
: <T_THIS>
2532
;
2633

2734
StringLiteral -> { return $this->stringPool[$token] ??= $children; }

resources/grammar/ternary.pp2

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ OptionalTernaryExpressionSuffix
4040
;
4141

4242
TernaryExpressionSuffix
43-
: (<T_EQ>|<T_NEQ>) (VariableLiteral()|Type())
43+
: TernaryExpressionOperator() Type()
4444
::T_QMARK:: Type()
4545
::T_COLON:: Type()
4646
;
47+
48+
TernaryExpressionOperator
49+
: <T_EQ>
50+
| <T_NEQ>
51+
| <T_LTE>
52+
| <T_GTE>
53+
| <T_ANGLE_BRACKET_OPEN>
54+
| <T_ANGLE_BRACKET_CLOSE>
55+
;

0 commit comments

Comments
 (0)