string-to-code 0.2.3__py3-none-any.whl → 0.2.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.
- string_to_code/core.py +8 -5
- string_to_code/utils.py +3 -2
- {string_to_code-0.2.3.dist-info → string_to_code-0.2.4.dist-info}/METADATA +1 -1
- {string_to_code-0.2.3.dist-info → string_to_code-0.2.4.dist-info}/RECORD +6 -6
- {string_to_code-0.2.3.dist-info → string_to_code-0.2.4.dist-info}/LICENSE +0 -0
- {string_to_code-0.2.3.dist-info → string_to_code-0.2.4.dist-info}/WHEEL +0 -0
string_to_code/core.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
core functions of the string_to_code module
|
|
3
3
|
"""
|
|
4
4
|
import typing
|
|
5
|
-
import collections
|
|
6
5
|
import random
|
|
7
6
|
import functools
|
|
8
7
|
|
|
@@ -13,12 +12,14 @@ class Atom(typing.NamedTuple):
|
|
|
13
12
|
atom_char: str
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
class SimpleFunction(
|
|
15
|
+
class SimpleFunction(typing.NamedTuple):
|
|
17
16
|
"""
|
|
18
17
|
represents a function with no arguments and no return value calling
|
|
19
18
|
other functions of such type or displaying single characters
|
|
20
19
|
"""
|
|
21
20
|
|
|
21
|
+
called_list: typing.List[int | Atom]
|
|
22
|
+
|
|
22
23
|
|
|
23
24
|
def str_pieces(in_str, in_pieces_len):
|
|
24
25
|
"""returns in_str splited into pieces of lengths as in in_pieces_len"""
|
|
@@ -68,11 +69,13 @@ def get_function_namer(in_name_prefix="f_"):
|
|
|
68
69
|
return _inner
|
|
69
70
|
|
|
70
71
|
|
|
71
|
-
def _prepare_printer_program(
|
|
72
|
-
|
|
72
|
+
def _prepare_printer_program(
|
|
73
|
+
in_str: str,
|
|
74
|
+
) -> typing.Tuple[int | Atom | None, typing.List[SimpleFunction]]:
|
|
75
|
+
needed_functions: typing.List[SimpleFunction] = []
|
|
73
76
|
|
|
74
77
|
@functools.lru_cache(maxsize=None)
|
|
75
|
-
def _generate_code(in_str):
|
|
78
|
+
def _generate_code(in_str: str) -> Atom | int:
|
|
76
79
|
if len(in_str) == 1:
|
|
77
80
|
return Atom(in_str)
|
|
78
81
|
|
string_to_code/utils.py
CHANGED
|
@@ -96,8 +96,9 @@ def get_function_to_code(
|
|
|
96
96
|
):
|
|
97
97
|
"""return function_to_code-like function"""
|
|
98
98
|
|
|
99
|
-
def _function_to_code(
|
|
100
|
-
|
|
99
|
+
def _function_to_code(
|
|
100
|
+
in_function_id: int, in_function: core.SimpleFunction, **kwargs
|
|
101
|
+
) -> str:
|
|
101
102
|
function_name = in_get_function_name(in_function_id, **kwargs)
|
|
102
103
|
function_body = in_body_to_str(in_function)
|
|
103
104
|
res = in_merge_to_full_function(function_name, function_body)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
string_to_code/README.md,sha256=A8BkDQpr-Os630YfGnaU-i_kigyVB8bNLhvLfIyzQR8,1225
|
|
2
2
|
string_to_code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
string_to_code/c_like_utils.py,sha256=G2HMxU6J9Lczv28yTNJSXLAeTyOHY1RV6gKltvf1h1E,2091
|
|
4
|
-
string_to_code/core.py,sha256=
|
|
4
|
+
string_to_code/core.py,sha256=nOAmOaHSX4S7_iVjHpZToW-MeZIiaQNaGONA4URS5YM,3854
|
|
5
5
|
string_to_code/string_to_code.py,sha256=ldAczke3qmY4UnodSP6oaq-Gu89IOubZAXUDflpo61k,1212
|
|
6
6
|
string_to_code/to_ada.py,sha256=-QUNxghg4KcZzqya0YgBoHJnFA2aYwnjw28Qec-EqJc,2264
|
|
7
7
|
string_to_code/to_algol68.py,sha256=ENxJbUKIL-iOXz3QrhXdGVUhrv5b_Ogjt_1NLrYbZjY,1641
|
|
@@ -17,8 +17,8 @@ string_to_code/to_nim.py,sha256=QolGTXNj764qZOEkYJ0uSBhda1tdQCgnYqgUqyrVTMw,1533
|
|
|
17
17
|
string_to_code/to_pascal.py,sha256=EQ1wUQ-jz5frIB0_OQ3h2v8BDitzKFhVsey_xlX3XMg,1921
|
|
18
18
|
string_to_code/to_python3.py,sha256=ZLU29deSg-rsfR5HmlB5ZCH2pURGmGFdNDfcIZ_DdNU,1588
|
|
19
19
|
string_to_code/to_rust.py,sha256=xbkKKhvFxbOBtSgh-5_hGJ8zSBDt4vNIqEiJW9JsoXw,1925
|
|
20
|
-
string_to_code/utils.py,sha256=
|
|
21
|
-
string_to_code-0.2.
|
|
22
|
-
string_to_code-0.2.
|
|
23
|
-
string_to_code-0.2.
|
|
24
|
-
string_to_code-0.2.
|
|
20
|
+
string_to_code/utils.py,sha256=P3qkuOtsZbhejTnouIUuz4qM_tvNrWBkzrX8NOztmok,3368
|
|
21
|
+
string_to_code-0.2.4.dist-info/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
|
|
22
|
+
string_to_code-0.2.4.dist-info/METADATA,sha256=oszbBWRvuBm1VsYQeCI5KurDfbsXwxfYfZ9NfISHAKg,1849
|
|
23
|
+
string_to_code-0.2.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
24
|
+
string_to_code-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|