@mintplayer/polyglot-target-typescript 0.1.0 → 0.3.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.
- package/package.json +1 -1
- package/polyglot-plugin.json +276 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MintPlayer Polyglot TypeScript / JavaScript target — a pure-JSON language plugin (spec + emission rules + capabilities + std bindings) for the polyglot transpiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyglot",
|
package/polyglot-plugin.json
CHANGED
|
@@ -367,6 +367,30 @@
|
|
|
367
367
|
},
|
|
368
368
|
{
|
|
369
369
|
"get": "spec.delimited.list.close"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"case": {
|
|
373
|
+
"when": [
|
|
374
|
+
[
|
|
375
|
+
{
|
|
376
|
+
"eq": [
|
|
377
|
+
"node.elements.count",
|
|
378
|
+
"0"
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"tmpl": [
|
|
383
|
+
" as ",
|
|
384
|
+
{
|
|
385
|
+
"type": "node.elem"
|
|
386
|
+
},
|
|
387
|
+
"[]"
|
|
388
|
+
]
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
],
|
|
392
|
+
"else": ""
|
|
393
|
+
}
|
|
370
394
|
}
|
|
371
395
|
]
|
|
372
396
|
},
|
|
@@ -666,20 +690,12 @@
|
|
|
666
690
|
]
|
|
667
691
|
},
|
|
668
692
|
{
|
|
669
|
-
"
|
|
670
|
-
|
|
693
|
+
"tmpl": [
|
|
694
|
+
"Math.trunc(",
|
|
671
695
|
{
|
|
672
|
-
"
|
|
696
|
+
"emit": "node.operand"
|
|
673
697
|
},
|
|
674
|
-
|
|
675
|
-
"tmpl": [
|
|
676
|
-
"Math.trunc(",
|
|
677
|
-
{
|
|
678
|
-
"emit": "node.operand"
|
|
679
|
-
},
|
|
680
|
-
")"
|
|
681
|
-
]
|
|
682
|
-
}
|
|
698
|
+
")"
|
|
683
699
|
]
|
|
684
700
|
}
|
|
685
701
|
]
|
|
@@ -1129,7 +1145,7 @@
|
|
|
1129
1145
|
}
|
|
1130
1146
|
}
|
|
1131
1147
|
},
|
|
1132
|
-
"})()"
|
|
1148
|
+
"throw new Error(\"non-exhaustive match\"); })()"
|
|
1133
1149
|
]
|
|
1134
1150
|
},
|
|
1135
1151
|
"Lambda": {
|
|
@@ -1208,7 +1224,7 @@
|
|
|
1208
1224
|
{
|
|
1209
1225
|
"line": {
|
|
1210
1226
|
"tmpl": [
|
|
1211
|
-
"type ",
|
|
1227
|
+
"export type ",
|
|
1212
1228
|
{
|
|
1213
1229
|
"fn": "ident",
|
|
1214
1230
|
"args": [
|
|
@@ -1224,7 +1240,7 @@
|
|
|
1224
1240
|
{
|
|
1225
1241
|
"line": {
|
|
1226
1242
|
"tmpl": [
|
|
1227
|
-
"const ",
|
|
1243
|
+
"export const ",
|
|
1228
1244
|
{
|
|
1229
1245
|
"fn": "ident",
|
|
1230
1246
|
"args": [
|
|
@@ -1465,7 +1481,7 @@
|
|
|
1465
1481
|
},
|
|
1466
1482
|
"tsRecordHead": {
|
|
1467
1483
|
"tmpl": [
|
|
1468
|
-
"class ",
|
|
1484
|
+
"export class ",
|
|
1469
1485
|
{
|
|
1470
1486
|
"fn": "ident",
|
|
1471
1487
|
"args": [
|
|
@@ -1607,6 +1623,9 @@
|
|
|
1607
1623
|
}
|
|
1608
1624
|
]
|
|
1609
1625
|
},
|
|
1626
|
+
{
|
|
1627
|
+
"fn": "generics"
|
|
1628
|
+
},
|
|
1610
1629
|
"): boolean"
|
|
1611
1630
|
]
|
|
1612
1631
|
},
|
|
@@ -1740,6 +1759,18 @@
|
|
|
1740
1759
|
},
|
|
1741
1760
|
{
|
|
1742
1761
|
"indent": [
|
|
1762
|
+
{
|
|
1763
|
+
"case": {
|
|
1764
|
+
"when": [
|
|
1765
|
+
[
|
|
1766
|
+
{
|
|
1767
|
+
"eq": [
|
|
1768
|
+
"stmt.catchesHaveGuard",
|
|
1769
|
+
"true"
|
|
1770
|
+
]
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
"seq": [
|
|
1743
1774
|
{
|
|
1744
1775
|
"line": "let __handled = false;"
|
|
1745
1776
|
},
|
|
@@ -1885,6 +1916,188 @@
|
|
|
1885
1916
|
]
|
|
1886
1917
|
]
|
|
1887
1918
|
}
|
|
1919
|
+
}
|
|
1920
|
+
]
|
|
1921
|
+
}
|
|
1922
|
+
]
|
|
1923
|
+
],
|
|
1924
|
+
"else": {
|
|
1925
|
+
"seq": [
|
|
1926
|
+
{
|
|
1927
|
+
"mapDecl": "stmt.catches",
|
|
1928
|
+
"each": {
|
|
1929
|
+
"case": {
|
|
1930
|
+
"when": [
|
|
1931
|
+
[
|
|
1932
|
+
{
|
|
1933
|
+
"eq": [
|
|
1934
|
+
"item.hasType",
|
|
1935
|
+
"true"
|
|
1936
|
+
]
|
|
1937
|
+
},
|
|
1938
|
+
{
|
|
1939
|
+
"seq": [
|
|
1940
|
+
{
|
|
1941
|
+
"line": {
|
|
1942
|
+
"tmpl": [
|
|
1943
|
+
{
|
|
1944
|
+
"case": {
|
|
1945
|
+
"when": [
|
|
1946
|
+
[
|
|
1947
|
+
{
|
|
1948
|
+
"eq": [
|
|
1949
|
+
"item.#",
|
|
1950
|
+
"0"
|
|
1951
|
+
]
|
|
1952
|
+
},
|
|
1953
|
+
"if ("
|
|
1954
|
+
]
|
|
1955
|
+
],
|
|
1956
|
+
"else": "else if ("
|
|
1957
|
+
}
|
|
1958
|
+
},
|
|
1959
|
+
"__e instanceof ",
|
|
1960
|
+
{
|
|
1961
|
+
"type": "item.type"
|
|
1962
|
+
},
|
|
1963
|
+
") {"
|
|
1964
|
+
]
|
|
1965
|
+
}
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
"indent": [
|
|
1969
|
+
{
|
|
1970
|
+
"case": {
|
|
1971
|
+
"when": [
|
|
1972
|
+
[
|
|
1973
|
+
{
|
|
1974
|
+
"eq": [
|
|
1975
|
+
"item.hasBinding",
|
|
1976
|
+
"true"
|
|
1977
|
+
]
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
"line": {
|
|
1981
|
+
"tmpl": [
|
|
1982
|
+
"const ",
|
|
1983
|
+
{
|
|
1984
|
+
"fn": "ident",
|
|
1985
|
+
"args": [
|
|
1986
|
+
{
|
|
1987
|
+
"get": "item.binding"
|
|
1988
|
+
}
|
|
1989
|
+
]
|
|
1990
|
+
},
|
|
1991
|
+
" = __e;"
|
|
1992
|
+
]
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
]
|
|
1996
|
+
]
|
|
1997
|
+
}
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
"stmts": "item.body"
|
|
2001
|
+
}
|
|
2002
|
+
]
|
|
2003
|
+
},
|
|
2004
|
+
{
|
|
2005
|
+
"line": "}"
|
|
2006
|
+
}
|
|
2007
|
+
]
|
|
2008
|
+
}
|
|
2009
|
+
]
|
|
2010
|
+
],
|
|
2011
|
+
"else": {
|
|
2012
|
+
"seq": [
|
|
2013
|
+
{
|
|
2014
|
+
"line": {
|
|
2015
|
+
"tmpl": [
|
|
2016
|
+
{
|
|
2017
|
+
"case": {
|
|
2018
|
+
"when": [
|
|
2019
|
+
[
|
|
2020
|
+
{
|
|
2021
|
+
"eq": [
|
|
2022
|
+
"item.#",
|
|
2023
|
+
"0"
|
|
2024
|
+
]
|
|
2025
|
+
},
|
|
2026
|
+
""
|
|
2027
|
+
]
|
|
2028
|
+
],
|
|
2029
|
+
"else": "else "
|
|
2030
|
+
}
|
|
2031
|
+
},
|
|
2032
|
+
"{"
|
|
2033
|
+
]
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
"indent": [
|
|
2038
|
+
{
|
|
2039
|
+
"case": {
|
|
2040
|
+
"when": [
|
|
2041
|
+
[
|
|
2042
|
+
{
|
|
2043
|
+
"eq": [
|
|
2044
|
+
"item.hasBinding",
|
|
2045
|
+
"true"
|
|
2046
|
+
]
|
|
2047
|
+
},
|
|
2048
|
+
{
|
|
2049
|
+
"line": {
|
|
2050
|
+
"tmpl": [
|
|
2051
|
+
"const ",
|
|
2052
|
+
{
|
|
2053
|
+
"fn": "ident",
|
|
2054
|
+
"args": [
|
|
2055
|
+
{
|
|
2056
|
+
"get": "item.binding"
|
|
2057
|
+
}
|
|
2058
|
+
]
|
|
2059
|
+
},
|
|
2060
|
+
" = __e;"
|
|
2061
|
+
]
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
]
|
|
2065
|
+
]
|
|
2066
|
+
}
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
"stmts": "item.body"
|
|
2070
|
+
}
|
|
2071
|
+
]
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
"line": "}"
|
|
2075
|
+
}
|
|
2076
|
+
]
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
},
|
|
2081
|
+
{
|
|
2082
|
+
"case": {
|
|
2083
|
+
"when": [
|
|
2084
|
+
[
|
|
2085
|
+
{
|
|
2086
|
+
"eq": [
|
|
2087
|
+
"stmt.hasCatchAll",
|
|
2088
|
+
"false"
|
|
2089
|
+
]
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
"line": "else { throw __e; }"
|
|
2093
|
+
}
|
|
2094
|
+
]
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
]
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
1888
2101
|
}
|
|
1889
2102
|
]
|
|
1890
2103
|
}
|
|
@@ -2070,6 +2283,26 @@
|
|
|
2070
2283
|
},
|
|
2071
2284
|
"Program": {
|
|
2072
2285
|
"seq": [
|
|
2286
|
+
{
|
|
2287
|
+
"mapDecl": "module.imports",
|
|
2288
|
+
"each": {
|
|
2289
|
+
"line": {
|
|
2290
|
+
"case": {
|
|
2291
|
+
"when": [
|
|
2292
|
+
[
|
|
2293
|
+
{ "eq": [ "item.isNamespace", "true" ] },
|
|
2294
|
+
{ "tmpl": [ "import * as ", { "get": "item.ns" }, " from \"./", { "get": "item.path" }, "\";" ] }
|
|
2295
|
+
],
|
|
2296
|
+
[
|
|
2297
|
+
{ "not": { "eq": [ "item.names", "" ] } },
|
|
2298
|
+
{ "tmpl": [ "import { ", { "get": "item.names" }, " } from \"./", { "get": "item.path" }, "\";" ] }
|
|
2299
|
+
]
|
|
2300
|
+
],
|
|
2301
|
+
"else": { "tmpl": [ "import \"./", { "get": "item.path" }, "\";" ] }
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
},
|
|
2073
2306
|
{
|
|
2074
2307
|
"mapMembers": "module.enums",
|
|
2075
2308
|
"rule": "EnumDecl"
|
|
@@ -2095,6 +2328,7 @@
|
|
|
2095
2328
|
"each": {
|
|
2096
2329
|
"line": {
|
|
2097
2330
|
"tmpl": [
|
|
2331
|
+
"export ",
|
|
2098
2332
|
{
|
|
2099
2333
|
"case": {
|
|
2100
2334
|
"when": [
|
|
@@ -2186,6 +2420,7 @@
|
|
|
2186
2420
|
},
|
|
2187
2421
|
"tsFnSig": {
|
|
2188
2422
|
"tmpl": [
|
|
2423
|
+
"export ",
|
|
2189
2424
|
{
|
|
2190
2425
|
"case": {
|
|
2191
2426
|
"when": [
|
|
@@ -2268,7 +2503,7 @@
|
|
|
2268
2503
|
},
|
|
2269
2504
|
"tsExtSig": {
|
|
2270
2505
|
"tmpl": [
|
|
2271
|
-
"function ",
|
|
2506
|
+
"export function ",
|
|
2272
2507
|
{
|
|
2273
2508
|
"fn": "ident",
|
|
2274
2509
|
"args": [
|
|
@@ -2333,7 +2568,7 @@
|
|
|
2333
2568
|
},
|
|
2334
2569
|
"tsClassHead": {
|
|
2335
2570
|
"tmpl": [
|
|
2336
|
-
"class ",
|
|
2571
|
+
"export class ",
|
|
2337
2572
|
{
|
|
2338
2573
|
"fn": "ident",
|
|
2339
2574
|
"args": [
|
|
@@ -2557,7 +2792,7 @@
|
|
|
2557
2792
|
"block": {
|
|
2558
2793
|
"head": {
|
|
2559
2794
|
"tmpl": [
|
|
2560
|
-
"interface ",
|
|
2795
|
+
"export interface ",
|
|
2561
2796
|
{
|
|
2562
2797
|
"fn": "ident",
|
|
2563
2798
|
"args": [
|
|
@@ -2678,7 +2913,7 @@
|
|
|
2678
2913
|
"UnionDecl": {
|
|
2679
2914
|
"line": {
|
|
2680
2915
|
"tmpl": [
|
|
2681
|
-
"type ",
|
|
2916
|
+
"export type ",
|
|
2682
2917
|
{
|
|
2683
2918
|
"fn": "ident",
|
|
2684
2919
|
"args": [
|
|
@@ -3246,17 +3481,33 @@
|
|
|
3246
3481
|
},
|
|
3247
3482
|
"std.io": {
|
|
3248
3483
|
"print": "console.log(String(x))",
|
|
3249
|
-
"readText": "
|
|
3250
|
-
"writeText": "
|
|
3251
|
-
"appendText": "
|
|
3252
|
-
"fileExists": "
|
|
3253
|
-
"deleteFile": "
|
|
3484
|
+
"readText": "process.getBuiltinModule('fs').readFileSync(path, 'utf8')",
|
|
3485
|
+
"writeText": "process.getBuiltinModule('fs').writeFileSync(path, content)",
|
|
3486
|
+
"appendText": "process.getBuiltinModule('fs').appendFileSync(path, content)",
|
|
3487
|
+
"fileExists": "process.getBuiltinModule('fs').existsSync(path)",
|
|
3488
|
+
"deleteFile": "process.getBuiltinModule('fs').unlinkSync(path)"
|
|
3254
3489
|
},
|
|
3255
3490
|
"std.math": {
|
|
3256
3491
|
"Math.PI": "Math.PI",
|
|
3257
3492
|
"Math.E": "Math.E",
|
|
3258
3493
|
"Math.sqrt": "Math.sqrt($0)",
|
|
3259
3494
|
"Math.ln": "Math.log($0)",
|
|
3495
|
+
"Math.log": "Math.log($0)",
|
|
3496
|
+
"Math.log2": "Math.log2($0)",
|
|
3497
|
+
"Math.log10": "Math.log10($0)",
|
|
3498
|
+
"Math.exp": "Math.exp($0)",
|
|
3499
|
+
"Math.pow": "Math.pow($0, $1)",
|
|
3500
|
+
"Math.sin": "Math.sin($0)",
|
|
3501
|
+
"Math.cos": "Math.cos($0)",
|
|
3502
|
+
"Math.tan": "Math.tan($0)",
|
|
3503
|
+
"Math.asin": "Math.asin($0)",
|
|
3504
|
+
"Math.acos": "Math.acos($0)",
|
|
3505
|
+
"Math.atan": "Math.atan($0)",
|
|
3506
|
+
"Math.atan2": "Math.atan2($0, $1)",
|
|
3507
|
+
"Math.sinh": "Math.sinh($0)",
|
|
3508
|
+
"Math.cosh": "Math.cosh($0)",
|
|
3509
|
+
"Math.tanh": "Math.tanh($0)",
|
|
3510
|
+
"Math.trunc": "Math.trunc($0)",
|
|
3260
3511
|
"Math.floor": "Math.floor($0)",
|
|
3261
3512
|
"Math.ceil": "Math.ceil($0)",
|
|
3262
3513
|
"Math.min": "((a, b) => (a <= b ? a : b))($0, $1)",
|