mhs-lang 2.2.3 → 3.0.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/README.md +47 -120
- package/bin/mhs.js +89 -80
- package/examples/demo_lengkap.mhs +12 -9
- package/examples/halo.mhs +7 -7
- package/examples/python_native.mhs +5 -4
- package/examples/rumus_elektronika.mhs +6 -6
- package/examples/tes_semua_modul.mhs +7 -7
- package/examples/utama_impor.mhs +8 -7
- package/package.json +6 -7
- package/src/index.js +87 -24
- package/src/language_server.js +56 -16
- package/src/lexer.js +444 -0
- package/src/modules/data_json.js +16 -4
- package/src/parser.js +1523 -0
- package/src/py_modules/data_json.py +13 -2
- package/src/py_transpiler.js +1281 -163
- package/src/rust_runtime.js +443 -0
- package/src/safety_analyzer.js +2139 -0
- package/src/stdlib.js +123 -58
- package/src/transpiler.js +813 -337
- package/LICENSE +0 -21
- package/assets/mhs-file-icons.vsix +0 -0
- package/assets/mhs.ico +0 -0
- package/assets/mhs.svg +0 -3
- package/scripts/postinstall.js +0 -276
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import json
|
|
2
2
|
|
|
3
|
+
def _mhs_unwrap_json(val):
|
|
4
|
+
while hasattr(val, "_get") and callable(getattr(val, "_get")):
|
|
5
|
+
val = val._get()
|
|
6
|
+
if isinstance(val, dict):
|
|
7
|
+
return {k: _mhs_unwrap_json(v) for k, v in val.items()}
|
|
8
|
+
if isinstance(val, list):
|
|
9
|
+
return [_mhs_unwrap_json(v) for v in val]
|
|
10
|
+
if isinstance(val, tuple):
|
|
11
|
+
return tuple(_mhs_unwrap_json(v) for v in val)
|
|
12
|
+
return val
|
|
13
|
+
|
|
3
14
|
urai = json.loads
|
|
4
15
|
|
|
5
16
|
def ubah_ke_teks(objek, rapi=False):
|
|
6
|
-
return json.dumps(objek, indent=2 if rapi else None)
|
|
17
|
+
return json.dumps(_mhs_unwrap_json(objek), indent=2 if rapi else None)
|
|
7
18
|
|
|
8
19
|
def baca_berkas(jalur):
|
|
9
20
|
with open(jalur, "r", encoding="utf-8") as f:
|
|
@@ -11,4 +22,4 @@ def baca_berkas(jalur):
|
|
|
11
22
|
|
|
12
23
|
def tulis_berkas(jalur, objek, rapi=True):
|
|
13
24
|
with open(jalur, "w", encoding="utf-8") as f:
|
|
14
|
-
json.dump(objek, f, indent=2 if rapi else None)
|
|
25
|
+
json.dump(_mhs_unwrap_json(objek), f, indent=2 if rapi else None)
|