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