pitonx 1.0.4__py3-none-any.whl
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.
- pitonx/__init__.py +7 -0
- pitonx/builtins.py +86 -0
- pitonx/cli.py +19 -0
- pitonx/core.py +41 -0
- pitonx/utils.py +6 -0
- pitonx-1.0.4.dist-info/METADATA +13 -0
- pitonx-1.0.4.dist-info/RECORD +11 -0
- pitonx-1.0.4.dist-info/WHEEL +5 -0
- pitonx-1.0.4.dist-info/entry_points.txt +2 -0
- pitonx-1.0.4.dist-info/licenses/LICENSE +21 -0
- pitonx-1.0.4.dist-info/top_level.txt +1 -0
pitonx/__init__.py
ADDED
pitonx/builtins.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
PITON_MAP = {
|
|
2
|
+
# Input / Output
|
|
3
|
+
'ketik': 'print',
|
|
4
|
+
'terima': 'input',
|
|
5
|
+
'buka': 'open',
|
|
6
|
+
'tutup': 'close',
|
|
7
|
+
'baca': 'read',
|
|
8
|
+
'tulis': 'write',
|
|
9
|
+
'barisbaca': 'readline',
|
|
10
|
+
'barisbacasemua': 'readlines',
|
|
11
|
+
|
|
12
|
+
# Fungsi & Kelas
|
|
13
|
+
'buat': 'def',
|
|
14
|
+
'kembalikan': 'return',
|
|
15
|
+
'wadah': 'class',
|
|
16
|
+
'anon': 'lambda',
|
|
17
|
+
'serahkan': 'yield',
|
|
18
|
+
'inisial': '__init__',
|
|
19
|
+
'str': '__str__',
|
|
20
|
+
'repr': '__repr__',
|
|
21
|
+
|
|
22
|
+
# Logika
|
|
23
|
+
'jika': 'if',
|
|
24
|
+
'jikalau': 'elif',
|
|
25
|
+
'selain': 'else',
|
|
26
|
+
'pasti': 'assert',
|
|
27
|
+
|
|
28
|
+
# Perulangan
|
|
29
|
+
'selagi': 'while',
|
|
30
|
+
'ulangi': 'for',
|
|
31
|
+
'henti': 'break',
|
|
32
|
+
'lanjut': 'continue',
|
|
33
|
+
'lewat': 'pass',
|
|
34
|
+
|
|
35
|
+
# Tipe Data
|
|
36
|
+
'teks': 'str',
|
|
37
|
+
'bilangan': 'int',
|
|
38
|
+
'desimal': 'float',
|
|
39
|
+
'logika': 'bool',
|
|
40
|
+
'daftar': 'list',
|
|
41
|
+
'kamus': 'dict',
|
|
42
|
+
'panjang': 'len',
|
|
43
|
+
'jenis': 'type',
|
|
44
|
+
'rentang': 'range',
|
|
45
|
+
|
|
46
|
+
# Boolean
|
|
47
|
+
'BENAR': 'True',
|
|
48
|
+
'SALAH': 'False',
|
|
49
|
+
'KOSONG': 'None',
|
|
50
|
+
|
|
51
|
+
# Operator Logika
|
|
52
|
+
'dan': 'and',
|
|
53
|
+
'atau': 'or',
|
|
54
|
+
'bukan': 'not',
|
|
55
|
+
'dalam': 'in',
|
|
56
|
+
'adalah': 'is',
|
|
57
|
+
|
|
58
|
+
# Modul & Import
|
|
59
|
+
'impor': 'import',
|
|
60
|
+
'dari': 'from',
|
|
61
|
+
'sbg': 'as',
|
|
62
|
+
|
|
63
|
+
# Error Handling
|
|
64
|
+
'coba': 'try',
|
|
65
|
+
'tangkapi': 'except',
|
|
66
|
+
'bersihkan': 'finally',
|
|
67
|
+
'lontar': 'raise',
|
|
68
|
+
|
|
69
|
+
# Variabel & Scope
|
|
70
|
+
'umum': 'global',
|
|
71
|
+
'lokal': 'nonlocal',
|
|
72
|
+
'hapus': 'del',
|
|
73
|
+
|
|
74
|
+
# Matematika
|
|
75
|
+
'maks': 'max',
|
|
76
|
+
'min': 'min',
|
|
77
|
+
'total': 'sum',
|
|
78
|
+
'urut': 'sorted',
|
|
79
|
+
'abs': 'abs',
|
|
80
|
+
'bulat': 'round',
|
|
81
|
+
'pangkat': 'pow',
|
|
82
|
+
|
|
83
|
+
# Khusus
|
|
84
|
+
'__nama__': '__name__',
|
|
85
|
+
'__utama__': '__main__'
|
|
86
|
+
}
|
pitonx/cli.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from .core import translate, run_pitonx
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
if len(sys.argv) < 2:
|
|
7
|
+
print("PitonX CLI")
|
|
8
|
+
print("Cara pakai: pitonx nama_file.pt")
|
|
9
|
+
return
|
|
10
|
+
file_path = sys.argv[1]
|
|
11
|
+
if not Path(file_path).exists():
|
|
12
|
+
print(f"File '{file_path}' tidak ditemukan.")
|
|
13
|
+
return
|
|
14
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
15
|
+
code = f.read()
|
|
16
|
+
try:
|
|
17
|
+
run_pitonx(code)
|
|
18
|
+
except Exception as e:
|
|
19
|
+
print(f"ERROR: {e}")
|
pitonx/core.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from .builtins import PITON_MAP
|
|
3
|
+
|
|
4
|
+
def translate(code):
|
|
5
|
+
lines = code.split('\n')
|
|
6
|
+
for i in range(len(lines)):
|
|
7
|
+
b = lines[i].strip()
|
|
8
|
+
if b and not b.startswith('=') and not b.startswith('jika') and not b.startswith('selagi') and not b.startswith('buat'):
|
|
9
|
+
if (b.startswith('"') and b.endswith('"')) or (b.startswith("'") and b.endswith("'")):
|
|
10
|
+
lines[i] = f'ketik({b})'
|
|
11
|
+
elif b.replace('.', '', 1).isdigit() or any(op in b for op in ['+', '-', '*', '/', '%']):
|
|
12
|
+
if '=' not in b:
|
|
13
|
+
lines[i] = f'ketik({b})'
|
|
14
|
+
elif b.endswith(';'):
|
|
15
|
+
lines[i] = f'ketik({b[:-1]})'
|
|
16
|
+
code = '\n'.join(lines)
|
|
17
|
+
strings = []
|
|
18
|
+
idx = 0
|
|
19
|
+
def save_string(match):
|
|
20
|
+
nonlocal idx
|
|
21
|
+
strings.append(match.group(0))
|
|
22
|
+
result = f'__S{idx}__'
|
|
23
|
+
idx += 1
|
|
24
|
+
return result
|
|
25
|
+
code = re.sub(r'"[^"\\]*(\\.[^"\\]*)*"', save_string, code)
|
|
26
|
+
code = re.sub(r"'[^'\\]*(\\.[^'\\]*)*'", save_string, code)
|
|
27
|
+
sorted_keys = sorted(PITON_MAP.keys(), key=len, reverse=True)
|
|
28
|
+
for key in sorted_keys:
|
|
29
|
+
code = re.sub(r'\b' + re.escape(key) + r'\b', PITON_MAP[key], code)
|
|
30
|
+
for i in range(len(strings)):
|
|
31
|
+
code = code.replace(f'__S{i}__', strings[i])
|
|
32
|
+
return code
|
|
33
|
+
|
|
34
|
+
def run_pitonx(code):
|
|
35
|
+
if isinstance(code, str) and not code.startswith('ketik'):
|
|
36
|
+
if code.strip().startswith('"') or code.strip().startswith("'"):
|
|
37
|
+
python_code = f"print({code.strip()})"
|
|
38
|
+
exec(python_code)
|
|
39
|
+
return
|
|
40
|
+
python_code = translate(code)
|
|
41
|
+
exec(python_code, {'__builtins__': __builtins__, 'print': print})
|
pitonx/utils.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pitonx
|
|
3
|
+
Version: 1.0.4
|
|
4
|
+
Summary: Bahasa Pemrograman Indonesia berbasis Python
|
|
5
|
+
Home-page: https://github.com/Fathirthe-founder1/PitonX
|
|
6
|
+
Author: Fathirthe-founder1
|
|
7
|
+
Requires-Python: >=3.6
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: home-page
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
Dynamic: requires-python
|
|
13
|
+
Dynamic: summary
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pitonx/__init__.py,sha256=KsgyDseRV_SbjZJJqY3ySvQvmFsptvPEXqgw39A2S3s,134
|
|
2
|
+
pitonx/builtins.py,sha256=5w-TIVykJbi6lWBmfM6SGnwvH66mA5AVRbFMTn6hHHY,1605
|
|
3
|
+
pitonx/cli.py,sha256=eJWpHp9KaJEgrxYZy0TkN3IksfMoiDfTwiXfbufuaec,509
|
|
4
|
+
pitonx/core.py,sha256=L7X68R2N5jCSccLfQXAipBtq0o8Isbqs2XOWaY_pp0E,1662
|
|
5
|
+
pitonx/utils.py,sha256=2-rdH9-KLBqL2m1VJwHojD0qI-kLrJP5hhHwfjnonkw,170
|
|
6
|
+
pitonx-1.0.4.dist-info/licenses/LICENSE,sha256=uQgO0PsUMVdpDYo6hoamQni9M7zcvN9mLhuQzuHAoOM,1078
|
|
7
|
+
pitonx-1.0.4.dist-info/METADATA,sha256=kdDD35J3q1LVBLm_0wp6V1IsXKK2C1qSm3wKX3Px3hE,331
|
|
8
|
+
pitonx-1.0.4.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
9
|
+
pitonx-1.0.4.dist-info/entry_points.txt,sha256=bccHlSYo3tRd4ta6MNHDPZ8KFyWkkT6nyPWnOa4vLFo,43
|
|
10
|
+
pitonx-1.0.4.dist-info/top_level.txt,sha256=W82rj1vpxzQcJicgq9GCMS5BxKDTOJRwVXc9Brf1xOU,7
|
|
11
|
+
pitonx-1.0.4.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jameson Greogory Void
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pitonx
|