@ant-yasa/uast-parser-php 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/package.json +1 -1
  2. package/package.json +1 -1
  3. package/src/index.ts +26 -0
  4. package/src/parser.ts +1234 -0
  5. package/tests/benchmark/base/advanced.php +20 -0
  6. package/tests/benchmark/base/advanced.php.json +1269 -0
  7. package/tests/benchmark/base/basic.php +3 -0
  8. package/tests/benchmark/base/basic.php.json +292 -0
  9. package/tests/benchmark/base/closure-class.php +24 -0
  10. package/tests/benchmark/base/closure-class.php.json +1623 -0
  11. package/tests/benchmark/base/control-flow.php +37 -0
  12. package/tests/benchmark/base/control-flow.php.json +2010 -0
  13. package/tests/benchmark/base/enum-trait-adapt.php +31 -0
  14. package/tests/benchmark/base/enum-trait-adapt.php.json +965 -0
  15. package/tests/benchmark/base/exprs.php +4 -0
  16. package/tests/benchmark/base/exprs.php.json +811 -0
  17. package/tests/benchmark/base/flow-extras.php +12 -0
  18. package/tests/benchmark/base/flow-extras.php.json +897 -0
  19. package/tests/benchmark/base/function.php +7 -0
  20. package/tests/benchmark/base/function.php.json +536 -0
  21. package/tests/benchmark/base/modern-php.php +13 -0
  22. package/tests/benchmark/base/modern-php.php.json +508 -0
  23. package/tests/benchmark/base/namespace.php +5 -0
  24. package/tests/benchmark/base/namespace.php.json +307 -0
  25. package/tests/benchmark/base/new-static.php +3 -0
  26. package/tests/benchmark/base/new-static.php.json +399 -0
  27. package/tests/benchmark/base/runtime.php +13 -0
  28. package/tests/benchmark/base/runtime.php.json +1095 -0
  29. package/tests/benchmark/base/strings-casts.php +17 -0
  30. package/tests/benchmark/base/strings-casts.php.json +1357 -0
  31. package/tests/benchmark/base/structures.php +26 -0
  32. package/tests/benchmark/base/structures.php.json +1582 -0
  33. package/tests/index.ts +87 -0
@@ -0,0 +1,811 @@
1
+ {
2
+ "type": "CompileUnit",
3
+ "body": [
4
+ {
5
+ "type": "ExpressionStatement",
6
+ "expression": {
7
+ "type": "AssignmentExpression",
8
+ "left": {
9
+ "type": "Identifier",
10
+ "name": "x",
11
+ "_meta": {
12
+ "loc": {
13
+ "start": {
14
+ "line": 2,
15
+ "column": 1
16
+ },
17
+ "end": {
18
+ "line": 2,
19
+ "column": 3
20
+ },
21
+ "sourcefile": "exprs.php"
22
+ }
23
+ },
24
+ "loc": {
25
+ "start": {
26
+ "line": 2,
27
+ "column": 1
28
+ },
29
+ "end": {
30
+ "line": 2,
31
+ "column": 3
32
+ },
33
+ "sourcefile": "exprs.php"
34
+ }
35
+ },
36
+ "right": {
37
+ "type": "BinaryExpression",
38
+ "operator": "+",
39
+ "left": {
40
+ "type": "BinaryExpression",
41
+ "operator": "+",
42
+ "left": {
43
+ "type": "Identifier",
44
+ "name": "a",
45
+ "_meta": {
46
+ "loc": {
47
+ "start": {
48
+ "line": 2,
49
+ "column": 6
50
+ },
51
+ "end": {
52
+ "line": 2,
53
+ "column": 8
54
+ },
55
+ "sourcefile": "exprs.php"
56
+ }
57
+ },
58
+ "loc": {
59
+ "start": {
60
+ "line": 2,
61
+ "column": 6
62
+ },
63
+ "end": {
64
+ "line": 2,
65
+ "column": 8
66
+ },
67
+ "sourcefile": "exprs.php"
68
+ }
69
+ },
70
+ "right": {
71
+ "type": "Literal",
72
+ "value": "-",
73
+ "literalType": "string",
74
+ "_meta": {
75
+ "loc": {
76
+ "start": {
77
+ "line": 2,
78
+ "column": 11
79
+ },
80
+ "end": {
81
+ "line": 2,
82
+ "column": 14
83
+ },
84
+ "sourcefile": "exprs.php"
85
+ },
86
+ "encapsed": true
87
+ },
88
+ "loc": {
89
+ "start": {
90
+ "line": 2,
91
+ "column": 11
92
+ },
93
+ "end": {
94
+ "line": 2,
95
+ "column": 14
96
+ },
97
+ "sourcefile": "exprs.php"
98
+ }
99
+ },
100
+ "_meta": {
101
+ "loc": {
102
+ "start": {
103
+ "line": 2,
104
+ "column": 6
105
+ },
106
+ "end": {
107
+ "line": 2,
108
+ "column": 14
109
+ },
110
+ "sourcefile": "exprs.php"
111
+ }
112
+ },
113
+ "loc": {
114
+ "start": {
115
+ "line": 2,
116
+ "column": 6
117
+ },
118
+ "end": {
119
+ "line": 2,
120
+ "column": 14
121
+ },
122
+ "sourcefile": "exprs.php"
123
+ }
124
+ },
125
+ "right": {
126
+ "type": "ConditionalExpression",
127
+ "test": {
128
+ "type": "Identifier",
129
+ "name": "b",
130
+ "_meta": {
131
+ "loc": {
132
+ "start": {
133
+ "line": 2,
134
+ "column": 18
135
+ },
136
+ "end": {
137
+ "line": 2,
138
+ "column": 20
139
+ },
140
+ "sourcefile": "exprs.php"
141
+ }
142
+ },
143
+ "loc": {
144
+ "start": {
145
+ "line": 2,
146
+ "column": 18
147
+ },
148
+ "end": {
149
+ "line": 2,
150
+ "column": 20
151
+ },
152
+ "sourcefile": "exprs.php"
153
+ }
154
+ },
155
+ "consequent": {
156
+ "type": "Literal",
157
+ "value": 1,
158
+ "literalType": "number",
159
+ "_meta": {
160
+ "loc": {
161
+ "start": {
162
+ "line": 2,
163
+ "column": 23
164
+ },
165
+ "end": {
166
+ "line": 2,
167
+ "column": 24
168
+ },
169
+ "sourcefile": "exprs.php"
170
+ }
171
+ },
172
+ "loc": {
173
+ "start": {
174
+ "line": 2,
175
+ "column": 23
176
+ },
177
+ "end": {
178
+ "line": 2,
179
+ "column": 24
180
+ },
181
+ "sourcefile": "exprs.php"
182
+ }
183
+ },
184
+ "alternative": {
185
+ "type": "Literal",
186
+ "value": 2,
187
+ "literalType": "number",
188
+ "_meta": {
189
+ "loc": {
190
+ "start": {
191
+ "line": 2,
192
+ "column": 27
193
+ },
194
+ "end": {
195
+ "line": 2,
196
+ "column": 28
197
+ },
198
+ "sourcefile": "exprs.php"
199
+ }
200
+ },
201
+ "loc": {
202
+ "start": {
203
+ "line": 2,
204
+ "column": 27
205
+ },
206
+ "end": {
207
+ "line": 2,
208
+ "column": 28
209
+ },
210
+ "sourcefile": "exprs.php"
211
+ }
212
+ },
213
+ "_meta": {
214
+ "loc": {
215
+ "start": {
216
+ "line": 2,
217
+ "column": 18
218
+ },
219
+ "end": {
220
+ "line": 2,
221
+ "column": 28
222
+ },
223
+ "sourcefile": "exprs.php"
224
+ }
225
+ },
226
+ "loc": {
227
+ "start": {
228
+ "line": 2,
229
+ "column": 18
230
+ },
231
+ "end": {
232
+ "line": 2,
233
+ "column": 28
234
+ },
235
+ "sourcefile": "exprs.php"
236
+ }
237
+ },
238
+ "_meta": {
239
+ "loc": {
240
+ "start": {
241
+ "line": 2,
242
+ "column": 6
243
+ },
244
+ "end": {
245
+ "line": 2,
246
+ "column": 29
247
+ },
248
+ "sourcefile": "exprs.php"
249
+ }
250
+ },
251
+ "loc": {
252
+ "start": {
253
+ "line": 2,
254
+ "column": 6
255
+ },
256
+ "end": {
257
+ "line": 2,
258
+ "column": 29
259
+ },
260
+ "sourcefile": "exprs.php"
261
+ }
262
+ },
263
+ "operator": "=",
264
+ "cloned": false,
265
+ "_meta": {
266
+ "loc": {
267
+ "start": {
268
+ "line": 2,
269
+ "column": 1
270
+ },
271
+ "end": {
272
+ "line": 2,
273
+ "column": 29
274
+ },
275
+ "sourcefile": "exprs.php"
276
+ }
277
+ },
278
+ "loc": {
279
+ "start": {
280
+ "line": 2,
281
+ "column": 1
282
+ },
283
+ "end": {
284
+ "line": 2,
285
+ "column": 29
286
+ },
287
+ "sourcefile": "exprs.php"
288
+ }
289
+ },
290
+ "_meta": {
291
+ "loc": {
292
+ "start": {
293
+ "line": 2,
294
+ "column": 1
295
+ },
296
+ "end": {
297
+ "line": 2,
298
+ "column": 30
299
+ },
300
+ "sourcefile": "exprs.php"
301
+ }
302
+ },
303
+ "loc": {
304
+ "start": {
305
+ "line": 2,
306
+ "column": 1
307
+ },
308
+ "end": {
309
+ "line": 2,
310
+ "column": 30
311
+ },
312
+ "sourcefile": "exprs.php"
313
+ }
314
+ },
315
+ {
316
+ "type": "ExpressionStatement",
317
+ "expression": {
318
+ "type": "AssignmentExpression",
319
+ "left": {
320
+ "type": "Identifier",
321
+ "name": "y",
322
+ "_meta": {
323
+ "loc": {
324
+ "start": {
325
+ "line": 3,
326
+ "column": 1
327
+ },
328
+ "end": {
329
+ "line": 3,
330
+ "column": 3
331
+ },
332
+ "sourcefile": "exprs.php"
333
+ }
334
+ },
335
+ "loc": {
336
+ "start": {
337
+ "line": 3,
338
+ "column": 1
339
+ },
340
+ "end": {
341
+ "line": 3,
342
+ "column": 3
343
+ },
344
+ "sourcefile": "exprs.php"
345
+ }
346
+ },
347
+ "right": {
348
+ "type": "UnaryExpression",
349
+ "operator": "!",
350
+ "argument": {
351
+ "type": "Identifier",
352
+ "name": "flag",
353
+ "_meta": {
354
+ "loc": {
355
+ "start": {
356
+ "line": 3,
357
+ "column": 7
358
+ },
359
+ "end": {
360
+ "line": 3,
361
+ "column": 12
362
+ },
363
+ "sourcefile": "exprs.php"
364
+ }
365
+ },
366
+ "loc": {
367
+ "start": {
368
+ "line": 3,
369
+ "column": 7
370
+ },
371
+ "end": {
372
+ "line": 3,
373
+ "column": 12
374
+ },
375
+ "sourcefile": "exprs.php"
376
+ }
377
+ },
378
+ "isSuffix": false,
379
+ "_meta": {
380
+ "loc": {
381
+ "start": {
382
+ "line": 3,
383
+ "column": 6
384
+ },
385
+ "end": {
386
+ "line": 3,
387
+ "column": 12
388
+ },
389
+ "sourcefile": "exprs.php"
390
+ }
391
+ },
392
+ "loc": {
393
+ "start": {
394
+ "line": 3,
395
+ "column": 6
396
+ },
397
+ "end": {
398
+ "line": 3,
399
+ "column": 12
400
+ },
401
+ "sourcefile": "exprs.php"
402
+ }
403
+ },
404
+ "operator": "=",
405
+ "cloned": false,
406
+ "_meta": {
407
+ "loc": {
408
+ "start": {
409
+ "line": 3,
410
+ "column": 1
411
+ },
412
+ "end": {
413
+ "line": 3,
414
+ "column": 12
415
+ },
416
+ "sourcefile": "exprs.php"
417
+ }
418
+ },
419
+ "loc": {
420
+ "start": {
421
+ "line": 3,
422
+ "column": 1
423
+ },
424
+ "end": {
425
+ "line": 3,
426
+ "column": 12
427
+ },
428
+ "sourcefile": "exprs.php"
429
+ }
430
+ },
431
+ "_meta": {
432
+ "loc": {
433
+ "start": {
434
+ "line": 3,
435
+ "column": 1
436
+ },
437
+ "end": {
438
+ "line": 3,
439
+ "column": 13
440
+ },
441
+ "sourcefile": "exprs.php"
442
+ }
443
+ },
444
+ "loc": {
445
+ "start": {
446
+ "line": 3,
447
+ "column": 1
448
+ },
449
+ "end": {
450
+ "line": 3,
451
+ "column": 13
452
+ },
453
+ "sourcefile": "exprs.php"
454
+ }
455
+ },
456
+ {
457
+ "type": "ExpressionStatement",
458
+ "expression": {
459
+ "type": "AssignmentExpression",
460
+ "left": {
461
+ "type": "Identifier",
462
+ "name": "f",
463
+ "_meta": {
464
+ "loc": {
465
+ "start": {
466
+ "line": 4,
467
+ "column": 1
468
+ },
469
+ "end": {
470
+ "line": 4,
471
+ "column": 3
472
+ },
473
+ "sourcefile": "exprs.php"
474
+ }
475
+ },
476
+ "loc": {
477
+ "start": {
478
+ "line": 4,
479
+ "column": 1
480
+ },
481
+ "end": {
482
+ "line": 4,
483
+ "column": 3
484
+ },
485
+ "sourcefile": "exprs.php"
486
+ }
487
+ },
488
+ "right": {
489
+ "type": "FunctionDefinition",
490
+ "id": null,
491
+ "parameters": [
492
+ {
493
+ "type": "VariableDeclaration",
494
+ "id": {
495
+ "type": "Identifier",
496
+ "name": "z",
497
+ "_meta": {
498
+ "loc": {
499
+ "start": {
500
+ "line": 4,
501
+ "column": 9
502
+ },
503
+ "end": {
504
+ "line": 4,
505
+ "column": 11
506
+ },
507
+ "sourcefile": "exprs.php"
508
+ }
509
+ },
510
+ "loc": {
511
+ "start": {
512
+ "line": 4,
513
+ "column": 9
514
+ },
515
+ "end": {
516
+ "line": 4,
517
+ "column": 11
518
+ },
519
+ "sourcefile": "exprs.php"
520
+ }
521
+ },
522
+ "init": null,
523
+ "cloned": false,
524
+ "varType": {
525
+ "type": "DynamicType",
526
+ "id": null,
527
+ "_meta": {}
528
+ },
529
+ "_meta": {
530
+ "variadic": false,
531
+ "loc": {
532
+ "start": {
533
+ "line": 4,
534
+ "column": 9
535
+ },
536
+ "end": {
537
+ "line": 4,
538
+ "column": 11
539
+ },
540
+ "sourcefile": "exprs.php"
541
+ }
542
+ },
543
+ "loc": {
544
+ "start": {
545
+ "line": 4,
546
+ "column": 9
547
+ },
548
+ "end": {
549
+ "line": 4,
550
+ "column": 11
551
+ },
552
+ "sourcefile": "exprs.php"
553
+ }
554
+ }
555
+ ],
556
+ "returnType": {
557
+ "type": "DynamicType",
558
+ "id": null,
559
+ "_meta": {}
560
+ },
561
+ "body": {
562
+ "type": "ScopedStatement",
563
+ "body": [
564
+ {
565
+ "type": "ReturnStatement",
566
+ "argument": {
567
+ "type": "BinaryExpression",
568
+ "operator": "+",
569
+ "left": {
570
+ "type": "Identifier",
571
+ "name": "z",
572
+ "_meta": {
573
+ "loc": {
574
+ "start": {
575
+ "line": 4,
576
+ "column": 16
577
+ },
578
+ "end": {
579
+ "line": 4,
580
+ "column": 18
581
+ },
582
+ "sourcefile": "exprs.php"
583
+ }
584
+ },
585
+ "loc": {
586
+ "start": {
587
+ "line": 4,
588
+ "column": 16
589
+ },
590
+ "end": {
591
+ "line": 4,
592
+ "column": 18
593
+ },
594
+ "sourcefile": "exprs.php"
595
+ }
596
+ },
597
+ "right": {
598
+ "type": "Literal",
599
+ "value": 1,
600
+ "literalType": "number",
601
+ "_meta": {
602
+ "loc": {
603
+ "start": {
604
+ "line": 4,
605
+ "column": 21
606
+ },
607
+ "end": {
608
+ "line": 4,
609
+ "column": 22
610
+ },
611
+ "sourcefile": "exprs.php"
612
+ }
613
+ },
614
+ "loc": {
615
+ "start": {
616
+ "line": 4,
617
+ "column": 21
618
+ },
619
+ "end": {
620
+ "line": 4,
621
+ "column": 22
622
+ },
623
+ "sourcefile": "exprs.php"
624
+ }
625
+ },
626
+ "_meta": {
627
+ "loc": {
628
+ "start": {
629
+ "line": 4,
630
+ "column": 16
631
+ },
632
+ "end": {
633
+ "line": 4,
634
+ "column": 22
635
+ },
636
+ "sourcefile": "exprs.php"
637
+ }
638
+ },
639
+ "loc": {
640
+ "start": {
641
+ "line": 4,
642
+ "column": 16
643
+ },
644
+ "end": {
645
+ "line": 4,
646
+ "column": 22
647
+ },
648
+ "sourcefile": "exprs.php"
649
+ }
650
+ },
651
+ "isYield": false,
652
+ "_meta": {
653
+ "loc": {
654
+ "start": {
655
+ "line": 4,
656
+ "column": 16
657
+ },
658
+ "end": {
659
+ "line": 4,
660
+ "column": 22
661
+ },
662
+ "sourcefile": "exprs.php"
663
+ }
664
+ },
665
+ "loc": {
666
+ "start": {
667
+ "line": 4,
668
+ "column": 16
669
+ },
670
+ "end": {
671
+ "line": 4,
672
+ "column": 22
673
+ },
674
+ "sourcefile": "exprs.php"
675
+ }
676
+ }
677
+ ],
678
+ "id": null,
679
+ "_meta": {
680
+ "loc": {
681
+ "start": {
682
+ "line": 4,
683
+ "column": 16
684
+ },
685
+ "end": {
686
+ "line": 4,
687
+ "column": 22
688
+ },
689
+ "sourcefile": "exprs.php"
690
+ }
691
+ },
692
+ "loc": {
693
+ "start": {
694
+ "line": 4,
695
+ "column": 16
696
+ },
697
+ "end": {
698
+ "line": 4,
699
+ "column": 22
700
+ },
701
+ "sourcefile": "exprs.php"
702
+ }
703
+ },
704
+ "modifiers": [],
705
+ "_meta": {
706
+ "loc": {
707
+ "start": {
708
+ "line": 4,
709
+ "column": 6
710
+ },
711
+ "end": {
712
+ "line": 4,
713
+ "column": 22
714
+ },
715
+ "sourcefile": "exprs.php"
716
+ }
717
+ },
718
+ "loc": {
719
+ "start": {
720
+ "line": 4,
721
+ "column": 6
722
+ },
723
+ "end": {
724
+ "line": 4,
725
+ "column": 22
726
+ },
727
+ "sourcefile": "exprs.php"
728
+ }
729
+ },
730
+ "operator": "=",
731
+ "cloned": false,
732
+ "_meta": {
733
+ "loc": {
734
+ "start": {
735
+ "line": 4,
736
+ "column": 1
737
+ },
738
+ "end": {
739
+ "line": 4,
740
+ "column": 22
741
+ },
742
+ "sourcefile": "exprs.php"
743
+ }
744
+ },
745
+ "loc": {
746
+ "start": {
747
+ "line": 4,
748
+ "column": 1
749
+ },
750
+ "end": {
751
+ "line": 4,
752
+ "column": 22
753
+ },
754
+ "sourcefile": "exprs.php"
755
+ }
756
+ },
757
+ "_meta": {
758
+ "loc": {
759
+ "start": {
760
+ "line": 4,
761
+ "column": 1
762
+ },
763
+ "end": {
764
+ "line": 4,
765
+ "column": 23
766
+ },
767
+ "sourcefile": "exprs.php"
768
+ }
769
+ },
770
+ "loc": {
771
+ "start": {
772
+ "line": 4,
773
+ "column": 1
774
+ },
775
+ "end": {
776
+ "line": 4,
777
+ "column": 23
778
+ },
779
+ "sourcefile": "exprs.php"
780
+ }
781
+ }
782
+ ],
783
+ "language": "php",
784
+ "languageVersion": null,
785
+ "uri": "exprs.php",
786
+ "version": "0.0.0",
787
+ "_meta": {
788
+ "loc": {
789
+ "start": {
790
+ "line": 1,
791
+ "column": 1
792
+ },
793
+ "end": {
794
+ "line": 5,
795
+ "column": 1
796
+ },
797
+ "sourcefile": "exprs.php"
798
+ }
799
+ },
800
+ "loc": {
801
+ "start": {
802
+ "line": 1,
803
+ "column": 1
804
+ },
805
+ "end": {
806
+ "line": 5,
807
+ "column": 1
808
+ },
809
+ "sourcefile": "exprs.php"
810
+ }
811
+ }