tojscript 1.0.2__tar.gz → 1.0.3__tar.gz
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.
- {tojscript-1.0.2 → tojscript-1.0.3}/PKG-INFO +1 -1
- {tojscript-1.0.2 → tojscript-1.0.3}/setup.py +1 -2
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript/__init__.py +26 -3
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/PKG-INFO +1 -1
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/SOURCES.txt +0 -1
- tojscript-1.0.2/README.md +0 -22
- {tojscript-1.0.2 → tojscript-1.0.3}/setup.cfg +0 -0
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/dependency_links.txt +0 -0
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/entry_points.txt +0 -0
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/requires.txt +0 -0
- {tojscript-1.0.2 → tojscript-1.0.3}/tojscript.egg-info/top_level.txt +0 -0
|
@@ -2,7 +2,9 @@ from colorama import Fore, Style, init
|
|
|
2
2
|
init()
|
|
3
3
|
import re
|
|
4
4
|
import sys
|
|
5
|
+
import codecs
|
|
5
6
|
|
|
7
|
+
# 🎨 Цвета
|
|
6
8
|
colors = {
|
|
7
9
|
"сабз": Fore.GREEN,
|
|
8
10
|
"сурх": Fore.RED,
|
|
@@ -79,6 +81,7 @@ TOJ_GLOBALS = {
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
def toj_to_python(code):
|
|
84
|
+
# убираем строки import tojscript
|
|
82
85
|
code = re.sub(r'^\s*import\s+tojscript\s*$', '', code, flags=re.MULTILINE)
|
|
83
86
|
|
|
84
87
|
translations = {
|
|
@@ -133,24 +136,44 @@ def toj_to_python(code):
|
|
|
133
136
|
return "\n".join(new_lines)
|
|
134
137
|
|
|
135
138
|
def runs(code):
|
|
139
|
+
"""Запуск таджикского кода из строки"""
|
|
136
140
|
python_code = toj_to_python(code)
|
|
137
141
|
try:
|
|
138
|
-
exec(python_code, TOJ_GLOBALS)
|
|
142
|
+
exec(python_code, {**TOJ_GLOBALS, **locals()})
|
|
139
143
|
except Exception as e:
|
|
140
144
|
print("Хато:", e)
|
|
141
145
|
|
|
142
146
|
def run(filename):
|
|
147
|
+
"""Запуск .toj или .py файла"""
|
|
143
148
|
with open(filename, "r", encoding="utf-8") as f:
|
|
144
149
|
code = f.read()
|
|
145
150
|
python_code = toj_to_python(code)
|
|
146
151
|
try:
|
|
147
|
-
exec(python_code, TOJ_GLOBALS)
|
|
152
|
+
exec(python_code, {**TOJ_GLOBALS, **locals()})
|
|
148
153
|
except Exception as e:
|
|
149
154
|
print("Хато:", e)
|
|
150
155
|
|
|
156
|
+
# 🔥 Хук: если запускают .py файл с таджикским кодом
|
|
157
|
+
class TojImportHook:
|
|
158
|
+
def find_module(self, name, path=None):
|
|
159
|
+
if name == "tojscript":
|
|
160
|
+
return self
|
|
161
|
+
return None
|
|
162
|
+
def load_module(self, name):
|
|
163
|
+
import types
|
|
164
|
+
mod = types.ModuleType(name)
|
|
165
|
+
mod.run = run
|
|
166
|
+
mod.runs = runs
|
|
167
|
+
mod.toj_to_python = toj_to_python
|
|
168
|
+
sys.modules[name] = mod
|
|
169
|
+
return mod
|
|
170
|
+
|
|
171
|
+
sys.meta_path.insert(0, TojImportHook())
|
|
172
|
+
|
|
151
173
|
def main():
|
|
152
174
|
if len(sys.argv) > 1:
|
|
153
|
-
|
|
175
|
+
filename = sys.argv[1]
|
|
176
|
+
run(filename)
|
|
154
177
|
else:
|
|
155
178
|
run("main.toj")
|
|
156
179
|
|
tojscript-1.0.2/README.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# TojScript 🇹🇯
|
|
2
|
-
Язык программирования на таджикском
|
|
3
|
-
|
|
4
|
-
## Установка
|
|
5
|
-
```
|
|
6
|
-
pip install tojscript
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Использование
|
|
10
|
-
```
|
|
11
|
-
toj main.toj
|
|
12
|
-
toj main.py
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Пример (main.toj)
|
|
16
|
-
```
|
|
17
|
-
оғоз() {
|
|
18
|
-
a = бутун(ворид())
|
|
19
|
-
b = бутун(ворид())
|
|
20
|
-
чоп(a+b)
|
|
21
|
-
}
|
|
22
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|