@mintplayer/polyglot-target-php 0.1.0

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 (2) hide show
  1. package/package.json +23 -0
  2. package/polyglot-plugin.json +1493 -0
@@ -0,0 +1,1493 @@
1
+ {
2
+ "schema": 1,
3
+ "name": "php",
4
+ "capabilities": {
5
+ "patternMatching": false,
6
+ "withExpressions": false,
7
+ "async": false,
8
+ "closures": false,
9
+ "exceptions": false,
10
+ "interfaces": false,
11
+ "blockLambdas": false,
12
+ "extensionMethods": false,
13
+ "operatorOverloading": false
14
+ },
15
+ "spec": {
16
+ "name": "php",
17
+ "scalarType": {},
18
+ "intSuffix": {},
19
+ "binaryOp": {},
20
+ "delimited": {
21
+ "tuple": {
22
+ "open": "[",
23
+ "sep": ", ",
24
+ "close": "]"
25
+ }
26
+ },
27
+ "blockStyle": "bracesKnR",
28
+ "stmtEnd": ";",
29
+ "throwKeyword": "throw",
30
+ "rethrow": "throw $__e;",
31
+ "trueLit": "true",
32
+ "falseLit": "false",
33
+ "nullLit": "null",
34
+ "wrapInt": {
35
+ "u8": "(($x) & 0xff)",
36
+ "u16": "(($x) & 0xffff)",
37
+ "u32": "(($x) & 0xffffffff)",
38
+ "i8": "(((($x) & 0xff) ^ 0x80) - 0x80)",
39
+ "i16": "(((($x) & 0xffff) ^ 0x8000) - 0x8000)",
40
+ "i32": "(((($x) & 0xffffffff) ^ 0x80000000) - 0x80000000)"
41
+ },
42
+ "wrapAtom": {
43
+ "recv": [
44
+ "binary",
45
+ "unary",
46
+ "cond",
47
+ "cast"
48
+ ],
49
+ "unary": [
50
+ "binary"
51
+ ]
52
+ },
53
+ "generics": {
54
+ "style": "",
55
+ "boundsIntro": "",
56
+ "boundsSep": "",
57
+ "erase": [
58
+ "INumber"
59
+ ]
60
+ },
61
+ "tables": {
62
+ "localDecl": {
63
+ "mutable": "$$x",
64
+ "const": "$$x"
65
+ },
66
+ "yield": {
67
+ "value": "yield $x;",
68
+ "empty": "return;"
69
+ }
70
+ },
71
+ "identifiers": {
72
+ "keywords": [
73
+ "abstract",
74
+ "and",
75
+ "array",
76
+ "as",
77
+ "break",
78
+ "callable",
79
+ "case",
80
+ "catch",
81
+ "class",
82
+ "clone",
83
+ "const",
84
+ "continue",
85
+ "declare",
86
+ "default",
87
+ "do",
88
+ "echo",
89
+ "else",
90
+ "elseif",
91
+ "empty",
92
+ "enddeclare",
93
+ "endfor",
94
+ "endforeach",
95
+ "endif",
96
+ "endswitch",
97
+ "endwhile",
98
+ "enum",
99
+ "extends",
100
+ "final",
101
+ "finally",
102
+ "fn",
103
+ "for",
104
+ "foreach",
105
+ "function",
106
+ "global",
107
+ "goto",
108
+ "if",
109
+ "implements",
110
+ "include",
111
+ "instanceof",
112
+ "insteadof",
113
+ "interface",
114
+ "isset",
115
+ "list",
116
+ "match",
117
+ "namespace",
118
+ "new",
119
+ "or",
120
+ "print",
121
+ "private",
122
+ "protected",
123
+ "public",
124
+ "readonly",
125
+ "require",
126
+ "return",
127
+ "static",
128
+ "switch",
129
+ "throw",
130
+ "trait",
131
+ "try",
132
+ "unset",
133
+ "use",
134
+ "var",
135
+ "while",
136
+ "xor",
137
+ "yield"
138
+ ],
139
+ "escape": {
140
+ "strategy": "suffix",
141
+ "with": "_"
142
+ },
143
+ "reserved": [
144
+ "__e",
145
+ "__opt*",
146
+ "__w*"
147
+ ]
148
+ },
149
+ "preludes": {}
150
+ },
151
+ "std": {
152
+ "std.io": {
153
+ "print": "echo is_bool($x) ? ($x ? \"true\" : \"false\") : $x, \"\\n\""
154
+ },
155
+ "std.core": {
156
+ "i32.parse": "(intval($0) & 0xffffffff)",
157
+ "f64.parse": "floatval($0)"
158
+ }
159
+ },
160
+ "rules": {
161
+ "Int": {
162
+ "get": "node.text"
163
+ },
164
+ "Float": {
165
+ "get": "node.text"
166
+ },
167
+ "Bool": {
168
+ "case": {
169
+ "when": [
170
+ [
171
+ {
172
+ "eq": [
173
+ "node.value",
174
+ "true"
175
+ ]
176
+ },
177
+ "true"
178
+ ]
179
+ ],
180
+ "else": "false"
181
+ }
182
+ },
183
+ "Null": "null",
184
+ "Str": {
185
+ "fn": "escapeString",
186
+ "args": [
187
+ {
188
+ "get": "node.value"
189
+ }
190
+ ]
191
+ },
192
+ "Char": {
193
+ "fn": "escapeString",
194
+ "args": [
195
+ {
196
+ "get": "node.value"
197
+ }
198
+ ]
199
+ },
200
+ "Var": {
201
+ "tmpl": [
202
+ "$",
203
+ {
204
+ "fn": "ident",
205
+ "args": [
206
+ {
207
+ "get": "node.name"
208
+ }
209
+ ]
210
+ }
211
+ ]
212
+ },
213
+ "This": "$this",
214
+ "Extern": {
215
+ "get": "node.code"
216
+ },
217
+ "Call": {
218
+ "tmpl": [
219
+ {
220
+ "fn": "ident",
221
+ "args": [
222
+ {
223
+ "get": "node.mangledCallee"
224
+ }
225
+ ]
226
+ },
227
+ "(",
228
+ {
229
+ "map": "node.args",
230
+ "sep": ", "
231
+ },
232
+ ")"
233
+ ]
234
+ },
235
+ "Member": {
236
+ "tmpl": [
237
+ {
238
+ "case": {
239
+ "when": [
240
+ [
241
+ {
242
+ "has": "node.staticType"
243
+ },
244
+ {
245
+ "tmpl": [
246
+ {
247
+ "get": "node.staticType"
248
+ },
249
+ "::"
250
+ ]
251
+ }
252
+ ]
253
+ ],
254
+ "else": {
255
+ "tmpl": [
256
+ {
257
+ "emitChild": "node.object",
258
+ "side": "recv"
259
+ },
260
+ {
261
+ "case": {
262
+ "when": [
263
+ [
264
+ {
265
+ "eq": [
266
+ "node.nullSafe",
267
+ "true"
268
+ ]
269
+ },
270
+ "?->"
271
+ ]
272
+ ],
273
+ "else": "->"
274
+ }
275
+ }
276
+ ]
277
+ }
278
+ }
279
+ },
280
+ {
281
+ "fn": "ident",
282
+ "args": [
283
+ {
284
+ "get": "node.field"
285
+ }
286
+ ]
287
+ }
288
+ ]
289
+ },
290
+ "MethodCall": {
291
+ "case": {
292
+ "when": [
293
+ [
294
+ {
295
+ "has": "node.staticType"
296
+ },
297
+ {
298
+ "tmpl": [
299
+ {
300
+ "get": "node.staticType"
301
+ },
302
+ "::",
303
+ {
304
+ "fn": "ident",
305
+ "args": [
306
+ {
307
+ "get": "node.method"
308
+ }
309
+ ]
310
+ },
311
+ "(",
312
+ {
313
+ "map": "node.args",
314
+ "sep": ", "
315
+ },
316
+ ")"
317
+ ]
318
+ }
319
+ ]
320
+ ],
321
+ "else": {
322
+ "tmpl": [
323
+ {
324
+ "emitChild": "node.object",
325
+ "side": "recv"
326
+ },
327
+ "->",
328
+ {
329
+ "fn": "ident",
330
+ "args": [
331
+ {
332
+ "get": "node.method"
333
+ }
334
+ ]
335
+ },
336
+ "(",
337
+ {
338
+ "map": "node.args",
339
+ "sep": ", "
340
+ },
341
+ ")"
342
+ ]
343
+ }
344
+ }
345
+ },
346
+ "Index": {
347
+ "case": {
348
+ "when": [
349
+ [
350
+ {
351
+ "eq": [
352
+ "node.receiverHasIndexer",
353
+ "true"
354
+ ]
355
+ },
356
+ {
357
+ "tmpl": [
358
+ {
359
+ "emitChild": "node.receiver",
360
+ "side": "recv"
361
+ },
362
+ "->get(",
363
+ {
364
+ "emit": "node.index"
365
+ },
366
+ ")"
367
+ ]
368
+ }
369
+ ]
370
+ ],
371
+ "else": {
372
+ "tmpl": [
373
+ {
374
+ "emitChild": "node.receiver",
375
+ "side": "recv"
376
+ },
377
+ "[",
378
+ {
379
+ "emit": "node.index"
380
+ },
381
+ "]"
382
+ ]
383
+ }
384
+ }
385
+ },
386
+ "Cond": {
387
+ "tmpl": [
388
+ "(",
389
+ {
390
+ "emit": "node.cond"
391
+ },
392
+ " ? ",
393
+ {
394
+ "emit": "node.then"
395
+ },
396
+ " : ",
397
+ {
398
+ "emit": "node.els"
399
+ },
400
+ ")"
401
+ ]
402
+ },
403
+ "ListLit": {
404
+ "tmpl": [
405
+ "[",
406
+ {
407
+ "map": "node.elements",
408
+ "sep": ", "
409
+ },
410
+ "]"
411
+ ]
412
+ },
413
+ "Tuple": {
414
+ "tmpl": [
415
+ "[",
416
+ {
417
+ "map": "node.elements",
418
+ "sep": ", "
419
+ },
420
+ "]"
421
+ ]
422
+ },
423
+ "New": {
424
+ "tmpl": [
425
+ "new ",
426
+ {
427
+ "fn": "ident",
428
+ "args": [
429
+ {
430
+ "get": "node.typeName"
431
+ }
432
+ ]
433
+ },
434
+ "(",
435
+ {
436
+ "map": "node.args",
437
+ "sep": ", "
438
+ },
439
+ ")"
440
+ ]
441
+ },
442
+ "Unary": {
443
+ "case": {
444
+ "when": [
445
+ [
446
+ {
447
+ "and": [
448
+ {
449
+ "eq": [
450
+ "node.op",
451
+ "-"
452
+ ]
453
+ },
454
+ {
455
+ "eq": [
456
+ "node.typeIsInt",
457
+ "true"
458
+ ]
459
+ }
460
+ ]
461
+ },
462
+ {
463
+ "fn": "wrap",
464
+ "args": [
465
+ {
466
+ "get": "node.type"
467
+ },
468
+ {
469
+ "tmpl": [
470
+ "-",
471
+ {
472
+ "emitChild": "node.operand",
473
+ "side": "unary"
474
+ }
475
+ ]
476
+ }
477
+ ]
478
+ }
479
+ ]
480
+ ],
481
+ "else": {
482
+ "tmpl": [
483
+ {
484
+ "get": "node.op"
485
+ },
486
+ {
487
+ "emitChild": "node.operand",
488
+ "side": "unary"
489
+ }
490
+ ]
491
+ }
492
+ }
493
+ },
494
+ "Cast": {
495
+ "case": {
496
+ "when": [
497
+ [
498
+ {
499
+ "eq": [
500
+ "node.castSame",
501
+ "true"
502
+ ]
503
+ },
504
+ {
505
+ "emit": "node.operand"
506
+ }
507
+ ],
508
+ [
509
+ {
510
+ "and": [
511
+ {
512
+ "eq": [
513
+ "node.typeIsFloat",
514
+ "true"
515
+ ]
516
+ },
517
+ {
518
+ "eq": [
519
+ "node.fromIsInt",
520
+ "true"
521
+ ]
522
+ }
523
+ ]
524
+ },
525
+ {
526
+ "tmpl": [
527
+ "(float)(",
528
+ {
529
+ "emit": "node.operand"
530
+ },
531
+ ")"
532
+ ]
533
+ }
534
+ ],
535
+ [
536
+ {
537
+ "eq": [
538
+ "node.typeIsFloat",
539
+ "true"
540
+ ]
541
+ },
542
+ {
543
+ "emit": "node.operand"
544
+ }
545
+ ],
546
+ [
547
+ {
548
+ "and": [
549
+ {
550
+ "eq": [
551
+ "node.typeIsInt",
552
+ "true"
553
+ ]
554
+ },
555
+ {
556
+ "eq": [
557
+ "node.fromIsFloat",
558
+ "true"
559
+ ]
560
+ }
561
+ ]
562
+ },
563
+ {
564
+ "fn": "wrap",
565
+ "args": [
566
+ {
567
+ "get": "node.type"
568
+ },
569
+ {
570
+ "tmpl": [
571
+ "(int)(",
572
+ {
573
+ "emit": "node.operand"
574
+ },
575
+ ")"
576
+ ]
577
+ }
578
+ ]
579
+ }
580
+ ]
581
+ ],
582
+ "else": {
583
+ "fn": "wrap",
584
+ "args": [
585
+ {
586
+ "get": "node.type"
587
+ },
588
+ {
589
+ "emit": "node.operand"
590
+ }
591
+ ]
592
+ }
593
+ }
594
+ },
595
+ "Interp": {
596
+ "tmpl": [
597
+ "(",
598
+ {
599
+ "interleave": {
600
+ "lits": "node.chunks",
601
+ "holes": "node.holes",
602
+ "lit": {
603
+ "fn": "escapeString",
604
+ "args": [
605
+ {
606
+ "get": "item"
607
+ }
608
+ ]
609
+ },
610
+ "hole": {
611
+ "tmpl": [
612
+ " . (",
613
+ {
614
+ "emit": "item"
615
+ },
616
+ ") . "
617
+ ]
618
+ }
619
+ }
620
+ },
621
+ ")"
622
+ ]
623
+ },
624
+ "Binary": {
625
+ "case": {
626
+ "when": [
627
+ [
628
+ {
629
+ "and": [
630
+ {
631
+ "eq": [
632
+ "node.op",
633
+ "+"
634
+ ]
635
+ },
636
+ {
637
+ "eq": [
638
+ "node.type",
639
+ "string"
640
+ ]
641
+ }
642
+ ]
643
+ },
644
+ {
645
+ "tmpl": [
646
+ {
647
+ "emitChild": "node.lhs",
648
+ "side": "l"
649
+ },
650
+ " . ",
651
+ {
652
+ "emitChild": "node.rhs",
653
+ "side": "r"
654
+ }
655
+ ]
656
+ }
657
+ ],
658
+ [
659
+ {
660
+ "and": [
661
+ {
662
+ "eq": [
663
+ "node.typeIsInt",
664
+ "true"
665
+ ]
666
+ },
667
+ {
668
+ "or": [
669
+ {
670
+ "eq": [
671
+ "node.op",
672
+ "+"
673
+ ]
674
+ },
675
+ {
676
+ "eq": [
677
+ "node.op",
678
+ "-"
679
+ ]
680
+ },
681
+ {
682
+ "eq": [
683
+ "node.op",
684
+ "*"
685
+ ]
686
+ },
687
+ {
688
+ "eq": [
689
+ "node.op",
690
+ "/"
691
+ ]
692
+ },
693
+ {
694
+ "eq": [
695
+ "node.op",
696
+ "%"
697
+ ]
698
+ }
699
+ ]
700
+ }
701
+ ]
702
+ },
703
+ {
704
+ "fn": "wrap",
705
+ "args": [
706
+ {
707
+ "get": "node.type"
708
+ },
709
+ {
710
+ "case": {
711
+ "when": [
712
+ [
713
+ {
714
+ "eq": [
715
+ "node.op",
716
+ "/"
717
+ ]
718
+ },
719
+ {
720
+ "tmpl": [
721
+ "intdiv(",
722
+ {
723
+ "emit": "node.lhs"
724
+ },
725
+ ", ",
726
+ {
727
+ "emit": "node.rhs"
728
+ },
729
+ ")"
730
+ ]
731
+ }
732
+ ]
733
+ ],
734
+ "else": {
735
+ "tmpl": [
736
+ {
737
+ "emitChild": "node.lhs",
738
+ "side": "l"
739
+ },
740
+ " ",
741
+ {
742
+ "get": "node.op"
743
+ },
744
+ " ",
745
+ {
746
+ "emitChild": "node.rhs",
747
+ "side": "r"
748
+ }
749
+ ]
750
+ }
751
+ }
752
+ }
753
+ ]
754
+ }
755
+ ]
756
+ ],
757
+ "else": {
758
+ "tmpl": [
759
+ {
760
+ "emitChild": "node.lhs",
761
+ "side": "l"
762
+ },
763
+ " ",
764
+ {
765
+ "fn": "opSpelling",
766
+ "args": [
767
+ {
768
+ "get": "node.op"
769
+ }
770
+ ]
771
+ },
772
+ " ",
773
+ {
774
+ "emitChild": "node.rhs",
775
+ "side": "r"
776
+ }
777
+ ]
778
+ }
779
+ }
780
+ },
781
+ "Type": {
782
+ "case": {
783
+ "when": [
784
+ [
785
+ {
786
+ "has": "type.externTemplate"
787
+ },
788
+ {
789
+ "fn": "substExtern"
790
+ }
791
+ ]
792
+ ],
793
+ "else": {
794
+ "fn": "ident",
795
+ "args": [
796
+ {
797
+ "get": "type.name"
798
+ }
799
+ ]
800
+ }
801
+ }
802
+ },
803
+ "ForStmt": {
804
+ "case": {
805
+ "when": [
806
+ [
807
+ {
808
+ "eq": [
809
+ "stmt.isRange",
810
+ "true"
811
+ ]
812
+ },
813
+ {
814
+ "block": {
815
+ "head": {
816
+ "tmpl": [
817
+ "for ($",
818
+ {
819
+ "fn": "ident",
820
+ "args": [
821
+ {
822
+ "get": "stmt.binding"
823
+ }
824
+ ]
825
+ },
826
+ " = ",
827
+ {
828
+ "emit": "stmt.rangeStart"
829
+ },
830
+ "; $",
831
+ {
832
+ "fn": "ident",
833
+ "args": [
834
+ {
835
+ "get": "stmt.binding"
836
+ }
837
+ ]
838
+ },
839
+ {
840
+ "case": {
841
+ "when": [
842
+ [
843
+ {
844
+ "eq": [
845
+ "stmt.inclusive",
846
+ "true"
847
+ ]
848
+ },
849
+ " <= "
850
+ ]
851
+ ],
852
+ "else": " < "
853
+ }
854
+ },
855
+ {
856
+ "emit": "stmt.rangeEnd"
857
+ },
858
+ "; $",
859
+ {
860
+ "fn": "ident",
861
+ "args": [
862
+ {
863
+ "get": "stmt.binding"
864
+ }
865
+ ]
866
+ },
867
+ "++)"
868
+ ]
869
+ },
870
+ "body": [
871
+ {
872
+ "stmts": "stmt.body"
873
+ }
874
+ ]
875
+ }
876
+ }
877
+ ],
878
+ [
879
+ {
880
+ "not": {
881
+ "eq": [
882
+ "stmt.tupleBindings.count",
883
+ "0"
884
+ ]
885
+ }
886
+ },
887
+ {
888
+ "block": {
889
+ "head": {
890
+ "tmpl": [
891
+ "foreach (",
892
+ {
893
+ "emit": "stmt.iterable"
894
+ },
895
+ " as [",
896
+ {
897
+ "map": "stmt.tupleBindings",
898
+ "sep": ", ",
899
+ "item": {
900
+ "tmpl": [
901
+ "$",
902
+ {
903
+ "get": "item"
904
+ }
905
+ ]
906
+ }
907
+ },
908
+ "])"
909
+ ]
910
+ },
911
+ "body": [
912
+ {
913
+ "stmts": "stmt.body"
914
+ }
915
+ ]
916
+ }
917
+ }
918
+ ]
919
+ ],
920
+ "else": {
921
+ "block": {
922
+ "head": {
923
+ "tmpl": [
924
+ "foreach (",
925
+ {
926
+ "emit": "stmt.iterable"
927
+ },
928
+ " as $",
929
+ {
930
+ "fn": "ident",
931
+ "args": [
932
+ {
933
+ "get": "stmt.binding"
934
+ }
935
+ ]
936
+ },
937
+ ")"
938
+ ]
939
+ },
940
+ "body": [
941
+ {
942
+ "stmts": "stmt.body"
943
+ }
944
+ ]
945
+ }
946
+ }
947
+ }
948
+ },
949
+ "phpParam": {
950
+ "tmpl": [
951
+ "$",
952
+ {
953
+ "fn": "ident",
954
+ "args": [
955
+ {
956
+ "get": "item.name"
957
+ }
958
+ ]
959
+ },
960
+ {
961
+ "case": {
962
+ "when": [
963
+ [
964
+ {
965
+ "eq": [
966
+ "item.hasDefault",
967
+ "true"
968
+ ]
969
+ },
970
+ {
971
+ "tmpl": [
972
+ " = ",
973
+ {
974
+ "emit": "item.default"
975
+ }
976
+ ]
977
+ }
978
+ ]
979
+ ]
980
+ }
981
+ }
982
+ ]
983
+ },
984
+ "phpFnSig": {
985
+ "tmpl": [
986
+ "function ",
987
+ {
988
+ "fn": "ident",
989
+ "args": [
990
+ {
991
+ "get": "decl.emitName"
992
+ }
993
+ ]
994
+ },
995
+ "(",
996
+ {
997
+ "map": "decl.params",
998
+ "sep": ", ",
999
+ "item": {
1000
+ "call": "phpParam"
1001
+ }
1002
+ },
1003
+ ")"
1004
+ ]
1005
+ },
1006
+ "FunctionDecl": {
1007
+ "block": {
1008
+ "head": {
1009
+ "call": "phpFnSig"
1010
+ },
1011
+ "body": [
1012
+ {
1013
+ "stmts": "decl.body"
1014
+ }
1015
+ ]
1016
+ }
1017
+ },
1018
+ "phpMethodSig": {
1019
+ "tmpl": [
1020
+ "public ",
1021
+ {
1022
+ "case": {
1023
+ "when": [
1024
+ [
1025
+ {
1026
+ "eq": [
1027
+ "decl.isStatic",
1028
+ "true"
1029
+ ]
1030
+ },
1031
+ "static "
1032
+ ]
1033
+ ]
1034
+ }
1035
+ },
1036
+ "function ",
1037
+ {
1038
+ "fn": "ident",
1039
+ "args": [
1040
+ {
1041
+ "get": "decl.name"
1042
+ }
1043
+ ]
1044
+ },
1045
+ "(",
1046
+ {
1047
+ "map": "decl.params",
1048
+ "sep": ", ",
1049
+ "item": {
1050
+ "call": "phpParam"
1051
+ }
1052
+ },
1053
+ ")"
1054
+ ]
1055
+ },
1056
+ "MethodDecl": {
1057
+ "block": {
1058
+ "head": {
1059
+ "call": "phpMethodSig"
1060
+ },
1061
+ "body": [
1062
+ {
1063
+ "case": {
1064
+ "when": [
1065
+ [
1066
+ {
1067
+ "eq": [
1068
+ "decl.exprBodied",
1069
+ "true"
1070
+ ]
1071
+ },
1072
+ {
1073
+ "line": {
1074
+ "tmpl": [
1075
+ "return ",
1076
+ {
1077
+ "emit": "decl.exprBody"
1078
+ },
1079
+ ";"
1080
+ ]
1081
+ }
1082
+ }
1083
+ ]
1084
+ ],
1085
+ "else": {
1086
+ "stmts": "decl.body"
1087
+ }
1088
+ }
1089
+ }
1090
+ ]
1091
+ }
1092
+ },
1093
+ "EnumDecl": {
1094
+ "block": {
1095
+ "head": {
1096
+ "tmpl": [
1097
+ "class ",
1098
+ {
1099
+ "fn": "ident",
1100
+ "args": [
1101
+ {
1102
+ "get": "decl.name"
1103
+ }
1104
+ ]
1105
+ }
1106
+ ]
1107
+ },
1108
+ "body": [
1109
+ {
1110
+ "mapDecl": "decl.cases",
1111
+ "each": {
1112
+ "line": {
1113
+ "tmpl": [
1114
+ "const ",
1115
+ {
1116
+ "fn": "ident",
1117
+ "args": [
1118
+ {
1119
+ "get": "item.name"
1120
+ }
1121
+ ]
1122
+ },
1123
+ " = ",
1124
+ {
1125
+ "get": "item.value"
1126
+ },
1127
+ ";"
1128
+ ]
1129
+ }
1130
+ }
1131
+ }
1132
+ ]
1133
+ }
1134
+ },
1135
+ "RecordDecl": {
1136
+ "block": {
1137
+ "head": {
1138
+ "tmpl": [
1139
+ "class ",
1140
+ {
1141
+ "fn": "ident",
1142
+ "args": [
1143
+ {
1144
+ "get": "decl.name"
1145
+ }
1146
+ ]
1147
+ }
1148
+ ]
1149
+ },
1150
+ "body": [
1151
+ {
1152
+ "mapDecl": "decl.fields",
1153
+ "each": {
1154
+ "line": {
1155
+ "tmpl": [
1156
+ "public $",
1157
+ {
1158
+ "fn": "ident",
1159
+ "args": [
1160
+ {
1161
+ "get": "item.name"
1162
+ }
1163
+ ]
1164
+ },
1165
+ ";"
1166
+ ]
1167
+ }
1168
+ }
1169
+ },
1170
+ {
1171
+ "block": {
1172
+ "head": {
1173
+ "tmpl": [
1174
+ "public function __construct(",
1175
+ {
1176
+ "map": "decl.fields",
1177
+ "sep": ", ",
1178
+ "item": {
1179
+ "tmpl": [
1180
+ "$",
1181
+ {
1182
+ "fn": "ident",
1183
+ "args": [
1184
+ {
1185
+ "get": "item.name"
1186
+ }
1187
+ ]
1188
+ }
1189
+ ]
1190
+ }
1191
+ },
1192
+ ")"
1193
+ ]
1194
+ },
1195
+ "body": [
1196
+ {
1197
+ "mapDecl": "decl.fields",
1198
+ "each": {
1199
+ "line": {
1200
+ "tmpl": [
1201
+ "$this->",
1202
+ {
1203
+ "fn": "ident",
1204
+ "args": [
1205
+ {
1206
+ "get": "item.name"
1207
+ }
1208
+ ]
1209
+ },
1210
+ " = $",
1211
+ {
1212
+ "fn": "ident",
1213
+ "args": [
1214
+ {
1215
+ "get": "item.name"
1216
+ }
1217
+ ]
1218
+ },
1219
+ ";"
1220
+ ]
1221
+ }
1222
+ }
1223
+ }
1224
+ ]
1225
+ }
1226
+ },
1227
+ {
1228
+ "mapMembers": "decl.methods",
1229
+ "rule": "MethodDecl"
1230
+ }
1231
+ ]
1232
+ }
1233
+ },
1234
+ "ClassDecl": {
1235
+ "block": {
1236
+ "head": {
1237
+ "tmpl": [
1238
+ "class ",
1239
+ {
1240
+ "fn": "ident",
1241
+ "args": [
1242
+ {
1243
+ "get": "decl.name"
1244
+ }
1245
+ ]
1246
+ },
1247
+ {
1248
+ "case": {
1249
+ "when": [
1250
+ [
1251
+ {
1252
+ "eq": [
1253
+ "decl.hasExtBase",
1254
+ "true"
1255
+ ]
1256
+ },
1257
+ {
1258
+ "tmpl": [
1259
+ " extends ",
1260
+ {
1261
+ "type": "decl.extBase"
1262
+ }
1263
+ ]
1264
+ }
1265
+ ]
1266
+ ]
1267
+ }
1268
+ }
1269
+ ]
1270
+ },
1271
+ "body": [
1272
+ {
1273
+ "mapDecl": "decl.fields",
1274
+ "each": {
1275
+ "line": {
1276
+ "tmpl": [
1277
+ "public ",
1278
+ {
1279
+ "case": {
1280
+ "when": [
1281
+ [
1282
+ {
1283
+ "eq": [
1284
+ "item.isStatic",
1285
+ "true"
1286
+ ]
1287
+ },
1288
+ "static "
1289
+ ]
1290
+ ]
1291
+ }
1292
+ },
1293
+ "$",
1294
+ {
1295
+ "fn": "ident",
1296
+ "args": [
1297
+ {
1298
+ "get": "item.name"
1299
+ }
1300
+ ]
1301
+ },
1302
+ {
1303
+ "case": {
1304
+ "when": [
1305
+ [
1306
+ {
1307
+ "eq": [
1308
+ "item.hasInit",
1309
+ "true"
1310
+ ]
1311
+ },
1312
+ {
1313
+ "tmpl": [
1314
+ " = ",
1315
+ {
1316
+ "emit": "item.init"
1317
+ }
1318
+ ]
1319
+ }
1320
+ ]
1321
+ ]
1322
+ }
1323
+ },
1324
+ ";"
1325
+ ]
1326
+ }
1327
+ }
1328
+ },
1329
+ {
1330
+ "case": {
1331
+ "when": [
1332
+ [
1333
+ {
1334
+ "eq": [
1335
+ "decl.hasInit",
1336
+ "true"
1337
+ ]
1338
+ },
1339
+ {
1340
+ "block": {
1341
+ "head": {
1342
+ "tmpl": [
1343
+ "public function __construct(",
1344
+ {
1345
+ "map": "decl.initParams",
1346
+ "sep": ", ",
1347
+ "item": {
1348
+ "call": "phpParam"
1349
+ }
1350
+ },
1351
+ ")"
1352
+ ]
1353
+ },
1354
+ "body": [
1355
+ {
1356
+ "case": {
1357
+ "when": [
1358
+ [
1359
+ {
1360
+ "eq": [
1361
+ "decl.hasSuper",
1362
+ "true"
1363
+ ]
1364
+ },
1365
+ {
1366
+ "line": {
1367
+ "tmpl": [
1368
+ "parent::__construct(",
1369
+ {
1370
+ "map": "decl.superArgs",
1371
+ "sep": ", ",
1372
+ "item": {
1373
+ "emit": "item"
1374
+ }
1375
+ },
1376
+ ");"
1377
+ ]
1378
+ }
1379
+ }
1380
+ ]
1381
+ ]
1382
+ }
1383
+ },
1384
+ {
1385
+ "stmts": "decl.initBody"
1386
+ }
1387
+ ]
1388
+ }
1389
+ }
1390
+ ]
1391
+ ]
1392
+ }
1393
+ },
1394
+ {
1395
+ "mapMembers": "decl.methods",
1396
+ "rule": "MethodDecl"
1397
+ }
1398
+ ]
1399
+ }
1400
+ },
1401
+ "Program": {
1402
+ "seq": [
1403
+ {
1404
+ "line": "<?php"
1405
+ },
1406
+ {
1407
+ "mapMembers": "module.enums",
1408
+ "rule": "EnumDecl"
1409
+ },
1410
+ {
1411
+ "mapMembers": "module.records",
1412
+ "rule": "RecordDecl"
1413
+ },
1414
+ {
1415
+ "mapMembers": "module.classes",
1416
+ "rule": "ClassDecl"
1417
+ },
1418
+ {
1419
+ "mapDecl": "module.globals",
1420
+ "each": {
1421
+ "line": {
1422
+ "tmpl": [
1423
+ "$",
1424
+ {
1425
+ "fn": "ident",
1426
+ "args": [
1427
+ {
1428
+ "get": "item.name"
1429
+ }
1430
+ ]
1431
+ },
1432
+ " = ",
1433
+ {
1434
+ "case": {
1435
+ "when": [
1436
+ [
1437
+ {
1438
+ "eq": [
1439
+ "item.hasInit",
1440
+ "true"
1441
+ ]
1442
+ },
1443
+ {
1444
+ "emit": "item.init"
1445
+ }
1446
+ ]
1447
+ ],
1448
+ "else": "null"
1449
+ }
1450
+ },
1451
+ ";"
1452
+ ]
1453
+ }
1454
+ }
1455
+ },
1456
+ {
1457
+ "mapMembers": "module.functions",
1458
+ "rule": "FunctionDecl"
1459
+ },
1460
+ {
1461
+ "case": {
1462
+ "when": [
1463
+ [
1464
+ {
1465
+ "eq": [
1466
+ "module.hasEntry",
1467
+ "true"
1468
+ ]
1469
+ },
1470
+ {
1471
+ "line": {
1472
+ "tmpl": [
1473
+ {
1474
+ "fn": "ident",
1475
+ "args": [
1476
+ {
1477
+ "get": "module.entry.mangledName"
1478
+ }
1479
+ ]
1480
+ },
1481
+ "();"
1482
+ ]
1483
+ }
1484
+ }
1485
+ ]
1486
+ ]
1487
+ }
1488
+ }
1489
+ ]
1490
+ }
1491
+ },
1492
+ "fileExtension": ".php"
1493
+ }