Skip to content

Commit 3c3301b

Browse files
committed
Remove extra xdebug handler and add source factory
1 parent f3d639c commit 3c3301b

File tree

3 files changed

+137
-139
lines changed

3 files changed

+137
-139
lines changed

resources/grammar.php

Lines changed: 109 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use TypeLang\Parser\Exception\FeatureNotAllowedException;
77

88
return [
9-
'initial' => 'Type',
9+
'initial' => 49,
1010
'tokens' => [
1111
'default' => [
1212
'T_DQ_STRING_LITERAL' => '"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"',
@@ -98,7 +98,7 @@
9898
37 => new \Phplrt\Parser\Grammar\Lexeme('T_ASTERISK', true),
9999
38 => new \Phplrt\Parser\Grammar\Lexeme('T_DOUBLE_COLON', false),
100100
39 => new \Phplrt\Parser\Grammar\Alternation([36, 3, 37]),
101-
40 => new \Phplrt\Parser\Grammar\Concatenation(['Type']),
101+
40 => new \Phplrt\Parser\Grammar\Concatenation([49]),
102102
41 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
103103
42 => new \Phplrt\Parser\Grammar\Concatenation([41, 40]),
104104
43 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
@@ -107,97 +107,97 @@
107107
46 => new \Phplrt\Parser\Grammar\Optional(43),
108108
47 => new \Phplrt\Parser\Grammar\Lexeme('T_ANGLE_BRACKET_CLOSE', false),
109109
48 => new \Phplrt\Parser\Grammar\Concatenation([44, 40, 45, 46, 47]),
110-
49 => new \Phplrt\Parser\Grammar\Concatenation([56, 60, 61]),
111-
50 => new \Phplrt\Parser\Grammar\Concatenation([75, 'Type']),
112-
51 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_OPEN', false),
113-
52 => new \Phplrt\Parser\Grammar\Optional(49),
114-
53 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_CLOSE', false),
115-
54 => new \Phplrt\Parser\Grammar\Optional(50),
116-
55 => new \Phplrt\Parser\Grammar\Concatenation([2, 51, 52, 53, 54]),
117-
56 => new \Phplrt\Parser\Grammar\Concatenation([62, 64]),
118-
57 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
119-
58 => new \Phplrt\Parser\Grammar\Concatenation([57, 56]),
120-
59 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
121-
60 => new \Phplrt\Parser\Grammar\Repetition(58, 0, INF),
122-
61 => new \Phplrt\Parser\Grammar\Optional(59),
123-
62 => new \Phplrt\Parser\Grammar\Concatenation([65, 66]),
124-
63 => new \Phplrt\Parser\Grammar\Lexeme('T_ASSIGN', true),
125-
64 => new \Phplrt\Parser\Grammar\Optional(63),
126-
65 => new \Phplrt\Parser\Grammar\Alternation([69, 72]),
127-
66 => new \Phplrt\Parser\Grammar\Optional(24),
128-
67 => new \Phplrt\Parser\Grammar\Concatenation(['Type', 74]),
129-
68 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
130-
69 => new \Phplrt\Parser\Grammar\Concatenation([68, 67]),
131-
70 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
132-
71 => new \Phplrt\Parser\Grammar\Optional(70),
133-
72 => new \Phplrt\Parser\Grammar\Concatenation([67, 71]),
134-
73 => new \Phplrt\Parser\Grammar\Lexeme('T_AMP', true),
135-
74 => new \Phplrt\Parser\Grammar\Optional(73),
136-
75 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
137-
76 => new \Phplrt\Parser\Grammar\Concatenation([91, 94]),
138-
77 => new \Phplrt\Parser\Grammar\Concatenation([89, 90]),
139-
78 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
140-
79 => new \Phplrt\Parser\Grammar\Concatenation([78, 77]),
141-
80 => new \Phplrt\Parser\Grammar\Optional(79),
142-
81 => new \Phplrt\Parser\Grammar\Concatenation([76, 80]),
143-
82 => new \Phplrt\Parser\Grammar\Optional(77),
144-
83 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
145-
84 => new \Phplrt\Parser\Grammar\Lexeme('T_BRACE_OPEN', false),
146-
85 => new \Phplrt\Parser\Grammar\Alternation([81, 82]),
147-
86 => new \Phplrt\Parser\Grammar\Optional(83),
148-
87 => new \Phplrt\Parser\Grammar\Lexeme('T_BRACE_CLOSE', false),
149-
88 => new \Phplrt\Parser\Grammar\Concatenation([84, 85, 86, 87]),
150-
89 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
151-
90 => new \Phplrt\Parser\Grammar\Optional(48),
152-
91 => new \Phplrt\Parser\Grammar\Alternation([95, 96]),
153-
92 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
154-
93 => new \Phplrt\Parser\Grammar\Concatenation([92, 91]),
155-
94 => new \Phplrt\Parser\Grammar\Repetition(93, 0, INF),
156-
95 => new \Phplrt\Parser\Grammar\Concatenation([97, 100, 101, 99]),
157-
96 => new \Phplrt\Parser\Grammar\Concatenation([99]),
158-
97 => new \Phplrt\Parser\Grammar\Alternation([3, 21, 19]),
159-
98 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', true),
160-
99 => new \Phplrt\Parser\Grammar\Concatenation(['Type']),
161-
100 => new \Phplrt\Parser\Grammar\Optional(98),
162-
101 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
163-
102 => new \Phplrt\Parser\Grammar\Alternation([48, 88]),
164-
103 => new \Phplrt\Parser\Grammar\Optional(102),
165-
104 => new \Phplrt\Parser\Grammar\Concatenation([2, 103]),
166-
105 => new \Phplrt\Parser\Grammar\Concatenation([118]),
167-
106 => new \Phplrt\Parser\Grammar\Optional(108),
168-
107 => new \Phplrt\Parser\Grammar\Concatenation([105, 106]),
169-
108 => new \Phplrt\Parser\Grammar\Concatenation([113, 114, 115, 'Type', 116, 'Type']),
170-
109 => new \Phplrt\Parser\Grammar\Concatenation([24, 108]),
171-
110 => new \Phplrt\Parser\Grammar\Alternation([107, 109]),
172-
111 => new \Phplrt\Parser\Grammar\Lexeme('T_EQ', true),
173-
112 => new \Phplrt\Parser\Grammar\Lexeme('T_NEQ', true),
174-
113 => new \Phplrt\Parser\Grammar\Alternation([111, 112]),
175-
114 => new \Phplrt\Parser\Grammar\Alternation([24, 'Type']),
176-
115 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', false),
177-
116 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
178-
117 => new \Phplrt\Parser\Grammar\Concatenation([110]),
179-
118 => new \Phplrt\Parser\Grammar\Concatenation([119, 122]),
180-
119 => new \Phplrt\Parser\Grammar\Concatenation([123, 126]),
181-
120 => new \Phplrt\Parser\Grammar\Lexeme('T_OR', false),
182-
121 => new \Phplrt\Parser\Grammar\Concatenation([120, 118]),
183-
122 => new \Phplrt\Parser\Grammar\Optional(121),
184-
123 => new \Phplrt\Parser\Grammar\Concatenation([127]),
185-
124 => new \Phplrt\Parser\Grammar\Lexeme('T_AMP', false),
186-
125 => new \Phplrt\Parser\Grammar\Concatenation([124, 119]),
187-
126 => new \Phplrt\Parser\Grammar\Optional(125),
188-
127 => new \Phplrt\Parser\Grammar\Alternation([130, 128]),
189-
128 => new \Phplrt\Parser\Grammar\Concatenation([131, 135]),
190-
129 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', true),
191-
130 => new \Phplrt\Parser\Grammar\Concatenation([129, 128]),
192-
132 => new \Phplrt\Parser\Grammar\Lexeme('T_SQUARE_BRACKET_OPEN', true),
193-
133 => new \Phplrt\Parser\Grammar\Lexeme('T_SQUARE_BRACKET_CLOSE', false),
194-
134 => new \Phplrt\Parser\Grammar\Concatenation([132, 133]),
195-
135 => new \Phplrt\Parser\Grammar\Repetition(134, 0, INF),
196-
136 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_OPEN', false),
197-
137 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_CLOSE', false),
198-
138 => new \Phplrt\Parser\Grammar\Concatenation([136, 'Type', 137]),
199-
'Type' => new \Phplrt\Parser\Grammar\Concatenation([117]),
200-
131 => new \Phplrt\Parser\Grammar\Alternation([138, 18, 55, 104])
110+
49 => new \Phplrt\Parser\Grammar\Concatenation([118]),
111+
50 => new \Phplrt\Parser\Grammar\Concatenation([57, 61, 62]),
112+
51 => new \Phplrt\Parser\Grammar\Concatenation([76, 49]),
113+
52 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_OPEN', false),
114+
53 => new \Phplrt\Parser\Grammar\Optional(50),
115+
54 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_CLOSE', false),
116+
55 => new \Phplrt\Parser\Grammar\Optional(51),
117+
56 => new \Phplrt\Parser\Grammar\Concatenation([2, 52, 53, 54, 55]),
118+
57 => new \Phplrt\Parser\Grammar\Concatenation([63, 65]),
119+
58 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
120+
59 => new \Phplrt\Parser\Grammar\Concatenation([58, 57]),
121+
60 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
122+
61 => new \Phplrt\Parser\Grammar\Repetition(59, 0, INF),
123+
62 => new \Phplrt\Parser\Grammar\Optional(60),
124+
63 => new \Phplrt\Parser\Grammar\Concatenation([66, 67]),
125+
64 => new \Phplrt\Parser\Grammar\Lexeme('T_ASSIGN', true),
126+
65 => new \Phplrt\Parser\Grammar\Optional(64),
127+
66 => new \Phplrt\Parser\Grammar\Alternation([70, 73]),
128+
67 => new \Phplrt\Parser\Grammar\Optional(24),
129+
68 => new \Phplrt\Parser\Grammar\Concatenation([49, 75]),
130+
69 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
131+
70 => new \Phplrt\Parser\Grammar\Concatenation([69, 68]),
132+
71 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
133+
72 => new \Phplrt\Parser\Grammar\Optional(71),
134+
73 => new \Phplrt\Parser\Grammar\Concatenation([68, 72]),
135+
74 => new \Phplrt\Parser\Grammar\Lexeme('T_AMP', true),
136+
75 => new \Phplrt\Parser\Grammar\Optional(74),
137+
76 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
138+
77 => new \Phplrt\Parser\Grammar\Concatenation([92, 95]),
139+
78 => new \Phplrt\Parser\Grammar\Concatenation([90, 91]),
140+
79 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
141+
80 => new \Phplrt\Parser\Grammar\Concatenation([79, 78]),
142+
81 => new \Phplrt\Parser\Grammar\Optional(80),
143+
82 => new \Phplrt\Parser\Grammar\Concatenation([77, 81]),
144+
83 => new \Phplrt\Parser\Grammar\Optional(78),
145+
84 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
146+
85 => new \Phplrt\Parser\Grammar\Lexeme('T_BRACE_OPEN', false),
147+
86 => new \Phplrt\Parser\Grammar\Alternation([82, 83]),
148+
87 => new \Phplrt\Parser\Grammar\Optional(84),
149+
88 => new \Phplrt\Parser\Grammar\Lexeme('T_BRACE_CLOSE', false),
150+
89 => new \Phplrt\Parser\Grammar\Concatenation([85, 86, 87, 88]),
151+
90 => new \Phplrt\Parser\Grammar\Lexeme('T_ELLIPSIS', true),
152+
91 => new \Phplrt\Parser\Grammar\Optional(48),
153+
92 => new \Phplrt\Parser\Grammar\Alternation([96, 97]),
154+
93 => new \Phplrt\Parser\Grammar\Lexeme('T_COMMA', false),
155+
94 => new \Phplrt\Parser\Grammar\Concatenation([93, 92]),
156+
95 => new \Phplrt\Parser\Grammar\Repetition(94, 0, INF),
157+
96 => new \Phplrt\Parser\Grammar\Concatenation([98, 101, 102, 100]),
158+
97 => new \Phplrt\Parser\Grammar\Concatenation([100]),
159+
98 => new \Phplrt\Parser\Grammar\Alternation([3, 21, 19]),
160+
99 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', true),
161+
100 => new \Phplrt\Parser\Grammar\Concatenation([49]),
162+
101 => new \Phplrt\Parser\Grammar\Optional(99),
163+
102 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
164+
103 => new \Phplrt\Parser\Grammar\Alternation([48, 89]),
165+
104 => new \Phplrt\Parser\Grammar\Optional(103),
166+
105 => new \Phplrt\Parser\Grammar\Concatenation([2, 104]),
167+
106 => new \Phplrt\Parser\Grammar\Concatenation([119]),
168+
107 => new \Phplrt\Parser\Grammar\Optional(109),
169+
108 => new \Phplrt\Parser\Grammar\Concatenation([106, 107]),
170+
109 => new \Phplrt\Parser\Grammar\Concatenation([114, 115, 116, 49, 117, 49]),
171+
110 => new \Phplrt\Parser\Grammar\Concatenation([24, 109]),
172+
111 => new \Phplrt\Parser\Grammar\Alternation([108, 110]),
173+
112 => new \Phplrt\Parser\Grammar\Lexeme('T_EQ', true),
174+
113 => new \Phplrt\Parser\Grammar\Lexeme('T_NEQ', true),
175+
114 => new \Phplrt\Parser\Grammar\Alternation([112, 113]),
176+
115 => new \Phplrt\Parser\Grammar\Alternation([24, 49]),
177+
116 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', false),
178+
117 => new \Phplrt\Parser\Grammar\Lexeme('T_COLON', false),
179+
118 => new \Phplrt\Parser\Grammar\Concatenation([111]),
180+
119 => new \Phplrt\Parser\Grammar\Concatenation([120, 123]),
181+
120 => new \Phplrt\Parser\Grammar\Concatenation([124, 127]),
182+
121 => new \Phplrt\Parser\Grammar\Lexeme('T_OR', false),
183+
122 => new \Phplrt\Parser\Grammar\Concatenation([121, 119]),
184+
123 => new \Phplrt\Parser\Grammar\Optional(122),
185+
124 => new \Phplrt\Parser\Grammar\Concatenation([128]),
186+
125 => new \Phplrt\Parser\Grammar\Lexeme('T_AMP', false),
187+
126 => new \Phplrt\Parser\Grammar\Concatenation([125, 120]),
188+
127 => new \Phplrt\Parser\Grammar\Optional(126),
189+
128 => new \Phplrt\Parser\Grammar\Alternation([131, 129]),
190+
129 => new \Phplrt\Parser\Grammar\Concatenation([132, 136]),
191+
130 => new \Phplrt\Parser\Grammar\Lexeme('T_QMARK', true),
192+
131 => new \Phplrt\Parser\Grammar\Concatenation([130, 129]),
193+
133 => new \Phplrt\Parser\Grammar\Lexeme('T_SQUARE_BRACKET_OPEN', true),
194+
134 => new \Phplrt\Parser\Grammar\Lexeme('T_SQUARE_BRACKET_CLOSE', false),
195+
135 => new \Phplrt\Parser\Grammar\Concatenation([133, 134]),
196+
136 => new \Phplrt\Parser\Grammar\Repetition(135, 0, INF),
197+
137 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_OPEN', false),
198+
138 => new \Phplrt\Parser\Grammar\Lexeme('T_PARENTHESIS_CLOSE', false),
199+
139 => new \Phplrt\Parser\Grammar\Concatenation([137, 49, 138]),
200+
132 => new \Phplrt\Parser\Grammar\Alternation([139, 18, 56, 105])
201201
],
202202
'reducers' => [
203203
0 => function (\Phplrt\Parser\Context $ctx, $children) {
@@ -279,7 +279,7 @@
279279
\is_array($children) ? $children[0] : $children,
280280
);
281281
},
282-
55 => function (\Phplrt\Parser\Context $ctx, $children) {
282+
56 => function (\Phplrt\Parser\Context $ctx, $children) {
283283
$token = $ctx->getToken();
284284
$offset = $token->getOffset();
285285
$name = \array_shift($children);
@@ -298,10 +298,10 @@
298298
type: isset($children[0]) ? $children[0] : null,
299299
);
300300
},
301-
49 => function (\Phplrt\Parser\Context $ctx, $children) {
301+
50 => function (\Phplrt\Parser\Context $ctx, $children) {
302302
return new Node\Stmt\Callable\ParametersListNode($children);
303303
},
304-
56 => function (\Phplrt\Parser\Context $ctx, $children) {
304+
57 => function (\Phplrt\Parser\Context $ctx, $children) {
305305
$token = $ctx->getToken();
306306
$offset = $token->getOffset();
307307
if (!isset($children[1])) {
@@ -315,15 +315,15 @@
315315
$children[0]->optional = true;
316316
return $children[0];
317317
},
318-
62 => function (\Phplrt\Parser\Context $ctx, $children) {
318+
63 => function (\Phplrt\Parser\Context $ctx, $children) {
319319
if (\count($children) === 1) {
320320
return $children[0];
321321
}
322322

323323
$children[0]->name = $children[1];
324324
return $children[0];
325325
},
326-
65 => function (\Phplrt\Parser\Context $ctx, $children) {
326+
66 => function (\Phplrt\Parser\Context $ctx, $children) {
327327
if (!isset($children[1])) {
328328
return $children[0];
329329
}
@@ -336,7 +336,7 @@
336336
$children[1]->variadic = true;
337337
return $children[1];
338338
},
339-
67 => function (\Phplrt\Parser\Context $ctx, $children) {
339+
68 => function (\Phplrt\Parser\Context $ctx, $children) {
340340
$argument = new Node\Stmt\Callable\ParameterNode($children[0]);
341341

342342
if (\count($children) !== 1) {
@@ -345,7 +345,7 @@
345345

346346
return $argument;
347347
},
348-
88 => function (\Phplrt\Parser\Context $ctx, $children) {
348+
89 => function (\Phplrt\Parser\Context $ctx, $children) {
349349
$token = $ctx->getToken();
350350
$offset = $token->getOffset();
351351
if ($children === []) {
@@ -372,7 +372,7 @@
372372

373373
return \array_filter([$parameters, $fields]);
374374
},
375-
76 => function (\Phplrt\Parser\Context $ctx, $children) {
375+
77 => function (\Phplrt\Parser\Context $ctx, $children) {
376376
$token = $ctx->getToken();
377377
$offset = $token->getOffset();
378378
$explicit = [];
@@ -398,7 +398,7 @@
398398

399399
return new Node\Stmt\Shape\FieldsListNode($children);
400400
},
401-
95 => function (\Phplrt\Parser\Context $ctx, $children) {
401+
96 => function (\Phplrt\Parser\Context $ctx, $children) {
402402
$name = $children[0];
403403
$value = \array_pop($children);
404404

@@ -413,10 +413,10 @@
413413
default => new Node\Stmt\Shape\NamedFieldNode($name, $value, $optional),
414414
};
415415
},
416-
96 => function (\Phplrt\Parser\Context $ctx, $children) {
416+
97 => function (\Phplrt\Parser\Context $ctx, $children) {
417417
return new Node\Stmt\Shape\ImplicitFieldNode($children[0]);
418418
},
419-
104 => function (\Phplrt\Parser\Context $ctx, $children) {
419+
105 => function (\Phplrt\Parser\Context $ctx, $children) {
420420
$fields = $parameters = null;
421421

422422
// Shape fields
@@ -435,7 +435,7 @@
435435
$fields,
436436
);
437437
},
438-
110 => function (\Phplrt\Parser\Context $ctx, $children) {
438+
111 => function (\Phplrt\Parser\Context $ctx, $children) {
439439
$token = $ctx->getToken();
440440
$offset = $token->getOffset();
441441
$count = \count($children);
@@ -469,28 +469,28 @@
469469
$children[4],
470470
);
471471
},
472-
118 => function (\Phplrt\Parser\Context $ctx, $children) {
472+
119 => function (\Phplrt\Parser\Context $ctx, $children) {
473473
if (\count($children) === 2) {
474474
return new Node\Stmt\UnionTypeNode($children[0], $children[1]);
475475
}
476476

477477
return $children;
478478
},
479-
119 => function (\Phplrt\Parser\Context $ctx, $children) {
479+
120 => function (\Phplrt\Parser\Context $ctx, $children) {
480480
if (\count($children) === 2) {
481481
return new Node\Stmt\IntersectionTypeNode($children[0], $children[1]);
482482
}
483483

484484
return $children;
485485
},
486-
127 => function (\Phplrt\Parser\Context $ctx, $children) {
486+
128 => function (\Phplrt\Parser\Context $ctx, $children) {
487487
if (\is_array($children)) {
488488
return new Node\Stmt\NullableTypeNode($children[1]);
489489
}
490490

491491
return $children;
492492
},
493-
128 => function (\Phplrt\Parser\Context $ctx, $children) {
493+
129 => function (\Phplrt\Parser\Context $ctx, $children) {
494494
$statement = \array_shift($children);
495495

496496
for ($i = 0, $length = \count($children); $i < $length; ++$i) {

resources/grammar.pp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*/
2828

29-
#Type
29+
Type
3030
: Expression()
3131
;
3232

0 commit comments

Comments
 (0)