mhs-lang 2.2.1 → 2.2.3
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/assets/mhs-file-icons.vsix +0 -0
- package/bin/mhs.js +7 -1
- package/package.json +1 -1
- package/src/index.js +3 -1
- package/src/language_server.js +1 -0
- package/src/py_transpiler.js +2 -1
- package/src/transpiler.js +2 -1
- package/examples/__pycache__/alat_py.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/berkas.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/data_json.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/jaringan.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/koleksi.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/kripto.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/matematika.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/modul_acak.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/pola.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/sistem.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/uji.cpython-312.pyc +0 -0
- package/src/py_modules/__pycache__/waktu.cpython-312.pyc +0 -0
|
Binary file
|
package/bin/mhs.js
CHANGED
|
@@ -21,6 +21,7 @@ Penggunaan:
|
|
|
21
21
|
mhs --js <file.mhs> Menampilkan hasil konversi ke JavaScript
|
|
22
22
|
mhs --lsp Menjalankan language server untuk editor berklien LSP
|
|
23
23
|
mhs init Membuat contoh halo.mhs & konfigurasi VS Code
|
|
24
|
+
mhs setup Memasang ulang ekstensi VSIX & ikon ke semua editor (VS Code, Cursor, Antigravity)
|
|
24
25
|
mhs Membuka mode interaktif (REPL)
|
|
25
26
|
mhs --version, -v Menampilkan versi
|
|
26
27
|
mhs --help, -h Menampilkan bantuan ini
|
|
@@ -142,13 +143,18 @@ function main() {
|
|
|
142
143
|
return;
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
if (cmd === 'setup' || cmd === 'pasang') {
|
|
147
|
+
require('../scripts/postinstall');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
145
151
|
if (cmd === '--js' || cmd === '--emit-py') {
|
|
146
152
|
const target = args[1];
|
|
147
153
|
if (!target) {
|
|
148
154
|
console.error(`Kesalahan: Harap sertakan nama file .mhs. Contoh: mhs ${cmd} halo.mhs`);
|
|
149
155
|
process.exit(1);
|
|
150
156
|
}
|
|
151
|
-
const source = fs.readFileSync(path.resolve(target), 'utf8');
|
|
157
|
+
const source = fs.readFileSync(path.resolve(target), 'utf8').replace(/^\uFEFF/, '');
|
|
152
158
|
console.log(cmd === '--emit-py' ? transpileToPython(source) : transpile(source));
|
|
153
159
|
return;
|
|
154
160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mhs-lang",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Bahasa pemrograman Python dalam Bahasa Indonesia (.mhs) dengan dual-engine Node.js + Python 3 native, dukungan impor .mhs, npm, dan modul Python (.py/pip).",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/index.js
CHANGED
|
@@ -91,6 +91,7 @@ function createImporter(baseDir, moduleCache) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function executeMhs(source, filename = '<mhs>', moduleCache = new Map()) {
|
|
94
|
+
source = source.replace(/^\uFEFF/, '');
|
|
94
95
|
const absFilename = filename.startsWith('<') ? filename : path.resolve(filename);
|
|
95
96
|
const baseDir = filename.startsWith('<') ? process.cwd() : path.dirname(absFilename);
|
|
96
97
|
|
|
@@ -127,7 +128,7 @@ function runFile(filePath, { engine = 'auto' } = {}) {
|
|
|
127
128
|
if (!fs.existsSync(absPath)) {
|
|
128
129
|
throw new Error(`File tidak ditemukan: ${absPath}`);
|
|
129
130
|
}
|
|
130
|
-
const source = fs.readFileSync(absPath, 'utf8');
|
|
131
|
+
const source = fs.readFileSync(absPath, 'utf8').replace(/^\uFEFF/, '');
|
|
131
132
|
|
|
132
133
|
if (engine === 'py' || (engine === 'auto' && hasPython3())) {
|
|
133
134
|
return runPyCode(source, absPath);
|
|
@@ -136,6 +137,7 @@ function runFile(filePath, { engine = 'auto' } = {}) {
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
function runPyCode(source, filename = '<mhs>') {
|
|
140
|
+
source = source.replace(/^\uFEFF/, '');
|
|
139
141
|
const absFilename = filename.startsWith('<') ? filename : path.resolve(filename);
|
|
140
142
|
const baseDir = filename.startsWith('<') ? process.cwd() : path.dirname(absFilename);
|
|
141
143
|
const pyModulesDir = path.resolve(__dirname, 'py_modules');
|
package/src/language_server.js
CHANGED
package/src/py_transpiler.js
CHANGED
|
@@ -222,7 +222,8 @@ function transformPyLine(rawLine) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
function transpileToPython(source, { includePrelude = true } = {}) {
|
|
225
|
-
const
|
|
225
|
+
const cleanSource = source.replace(/^\uFEFF/, '');
|
|
226
|
+
const lines = cleanSource.replace(/\r\n/g, '\n').split('\n');
|
|
226
227
|
const body = lines.map(transformPyLine).join('\n');
|
|
227
228
|
if (!includePrelude) return body;
|
|
228
229
|
return `${PY_PRELUDE}\n\n${body}\n`;
|
package/src/transpiler.js
CHANGED
|
@@ -156,7 +156,8 @@ function getIndent(line) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
function transpile(source) {
|
|
159
|
-
const
|
|
159
|
+
const cleanSource = source.replace(/^\uFEFF/, '');
|
|
160
|
+
const rawLines = cleanSource.replace(/\r\n/g, '\n').split('\n');
|
|
160
161
|
const indentStack = [0];
|
|
161
162
|
const scopeStack = [new Set(BUILTIN_NAMES)];
|
|
162
163
|
const blockTypeStack = ['root'];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|