@mintplayer/polyglot-target-python 0.1.0 → 0.2.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 +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MintPlayer Polyglot Python 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
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"rethrow": "raise",
|
|
39
39
|
"preludes": {
|
|
40
40
|
"asyncEntry": "import asyncio\n",
|
|
41
|
-
"idiv": "def _pg_idiv(a, b):\n q = a // b\n return q + 1 if (q < 0 and q * b != a) else q\ndef _pg_irem(a, b):\n return a - _pg_idiv(a, b) * b\n"
|
|
41
|
+
"idiv": "def _pg_idiv(a, b):\n q = a // b\n return q + 1 if (q < 0 and q * b != a) else q\ndef _pg_irem(a, b):\n return a - _pg_idiv(a, b) * b\n",
|
|
42
|
+
"fstr": "def _pg_str(x):\n if isinstance(x, bool):\n return \"true\" if x else \"false\"\n if isinstance(x, float) and x.is_integer() and abs(x) < 1e16:\n return str(int(x))\n return str(x)\n"
|
|
42
43
|
},
|
|
43
44
|
"tables": {
|
|
44
45
|
"localDecl": {
|
|
@@ -2035,7 +2036,13 @@
|
|
|
2035
2036
|
},
|
|
2036
2037
|
"hole": {
|
|
2037
2038
|
"tmpl": [
|
|
2038
|
-
|
|
2039
|
+
{
|
|
2040
|
+
"fn": "require",
|
|
2041
|
+
"args": [
|
|
2042
|
+
"fstr"
|
|
2043
|
+
]
|
|
2044
|
+
},
|
|
2045
|
+
" + _pg_str(",
|
|
2039
2046
|
{
|
|
2040
2047
|
"emit": "item"
|
|
2041
2048
|
},
|
|
@@ -2678,7 +2685,7 @@
|
|
|
2678
2685
|
"List.removeAt": "$this.pop($0)"
|
|
2679
2686
|
},
|
|
2680
2687
|
"std.io": {
|
|
2681
|
-
"print": "__builtins__.print(
|
|
2688
|
+
"print": "__builtins__.print((\"true\" if x else \"false\") if isinstance(x, bool) else (str(int(x)) if isinstance(x, float) and x.is_integer() and abs(x) < 1e16 else x))"
|
|
2682
2689
|
},
|
|
2683
2690
|
"std.math": {
|
|
2684
2691
|
"Math.PI": "__import__('math').pi",
|