string-to-code 0.2.11__py3-none-any.whl → 0.2.12__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/c_like_utils.py +15 -6
- string_to_code/core.py +2 -3
- string_to_code/utils.py +5 -3
- {string_to_code-0.2.11.dist-info → string_to_code-0.2.12.dist-info}/METADATA +2 -2
- {string_to_code-0.2.11.dist-info → string_to_code-0.2.12.dist-info}/RECORD +7 -7
- {string_to_code-0.2.11.dist-info → string_to_code-0.2.12.dist-info}/LICENSE +0 -0
- {string_to_code-0.2.11.dist-info → string_to_code-0.2.12.dist-info}/WHEEL +0 -0
string_to_code/c_like_utils.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"""
|
|
2
|
-
utilities
|
|
2
|
+
utilities for C-like languages
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import typing
|
|
6
|
+
|
|
5
7
|
from . import core
|
|
6
8
|
from . import utils
|
|
7
9
|
|
|
@@ -21,7 +23,10 @@ def escape_special_char(in_atom: core.Atom) -> str:
|
|
|
21
23
|
return special_chars.get(in_atom.atom_char, in_atom.atom_char)
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
def get_atom_to_code(
|
|
26
|
+
def get_atom_to_code(
|
|
27
|
+
in_printer_function_name: str,
|
|
28
|
+
in_escape_special_char_fun: typing.Callable[[core.Atom], str],
|
|
29
|
+
) -> typing.Callable[[core.Atom], str]:
|
|
25
30
|
"""returns the atom_to_code type function"""
|
|
26
31
|
|
|
27
32
|
def _inner(in_atom: core.Atom) -> str:
|
|
@@ -36,15 +41,19 @@ def get_function_call_str_fun(get_function_name):
|
|
|
36
41
|
return utils.get_function_call_str_fun(get_function_name, "", "();")
|
|
37
42
|
|
|
38
43
|
|
|
39
|
-
def get_body_to_str(
|
|
44
|
+
def get_body_to_str(
|
|
45
|
+
in_call_function_or_atom: typing.Callable[[core.CalledListEntry], str],
|
|
46
|
+
) -> typing.Callable[[core.SimpleFunction], str]:
|
|
40
47
|
"""returns body_to_str-like function for c-like languages"""
|
|
41
48
|
return utils.get_body_to_str("\n", " ", in_call_function_or_atom, "", "")
|
|
42
49
|
|
|
43
50
|
|
|
44
|
-
def get_merge_to_full_function(
|
|
51
|
+
def get_merge_to_full_function(
|
|
52
|
+
in_function_prefix: str,
|
|
53
|
+
) -> typing.Callable[[str, str], str]:
|
|
45
54
|
"""returns merge_to_full_function-like function for c-like languages"""
|
|
46
55
|
|
|
47
|
-
def _merge_to_full_function(in_function_name, in_function_body):
|
|
56
|
+
def _merge_to_full_function(in_function_name: str, in_function_body: str) -> str:
|
|
48
57
|
body_str = "\n" + in_function_body + "\n" if in_function_body else ""
|
|
49
58
|
return "\n".join(
|
|
50
59
|
[
|
|
@@ -59,7 +68,7 @@ def get_merge_to_full_function(in_function_prefix):
|
|
|
59
68
|
def get_main_call_fun(in_call_function_or_atom):
|
|
60
69
|
"""returns function returning code of main C or C++ function"""
|
|
61
70
|
|
|
62
|
-
def _main_call(in_initial_call, **kwargs):
|
|
71
|
+
def _main_call(in_initial_call: str | None, **kwargs) -> str:
|
|
63
72
|
initial_call_str = (
|
|
64
73
|
" " + in_call_function_or_atom(in_initial_call, **kwargs) + "\n "
|
|
65
74
|
if in_initial_call is not None
|
string_to_code/core.py
CHANGED
|
@@ -117,9 +117,8 @@ class PrinterProgram:
|
|
|
117
117
|
if self.initial_call is not None and not isinstance(self.initial_call, Atom):
|
|
118
118
|
assert self.needed_functions
|
|
119
119
|
if self.needed_functions:
|
|
120
|
-
assert isinstance(self.initial_call, int)
|
|
121
|
-
|
|
122
|
-
)
|
|
120
|
+
assert isinstance(self.initial_call, int)
|
|
121
|
+
assert self.initial_call + 1 == len(self.needed_functions)
|
|
123
122
|
for fun_id, fun in enumerate(self.needed_functions):
|
|
124
123
|
assert all(_ < fun_id for _ in fun.called_list if not isinstance(_, Atom))
|
|
125
124
|
|
string_to_code/utils.py
CHANGED
|
@@ -82,10 +82,10 @@ def get_all_proc_functions(main_call_to_code, function_to_code, join_to_final):
|
|
|
82
82
|
def get_body_to_str(
|
|
83
83
|
in_separator: str,
|
|
84
84
|
in_prefix: str,
|
|
85
|
-
in_call_function_or_atom,
|
|
85
|
+
in_call_function_or_atom: typing.Callable[[core.CalledListEntry], str],
|
|
86
86
|
in_postfix: str,
|
|
87
87
|
in_empty_result: str,
|
|
88
|
-
):
|
|
88
|
+
) -> typing.Callable[[core.SimpleFunction], str]:
|
|
89
89
|
"""returns body_to_str-like function"""
|
|
90
90
|
|
|
91
91
|
def _body_to_str(in_function: core.SimpleFunction) -> str:
|
|
@@ -100,7 +100,9 @@ def get_body_to_str(
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def get_function_to_code(
|
|
103
|
-
in_get_function_name,
|
|
103
|
+
in_get_function_name,
|
|
104
|
+
in_body_to_str: typing.Callable[[core.SimpleFunction], str],
|
|
105
|
+
in_merge_to_full_function: typing.Callable[[str, str], str],
|
|
104
106
|
):
|
|
105
107
|
"""return function_to_code-like function"""
|
|
106
108
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: string-to-code
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.12
|
|
4
4
|
Summary: Generates a piece of messy code in a given language displaying a given string
|
|
5
5
|
Home-page: https://github.com/vil02/string_to_code_proj
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: code-generation
|
|
8
8
|
Author: piotr.idzik
|
|
9
9
|
Author-email: vil02@o2.pl
|
|
10
|
-
Requires-Python: >=3.10
|
|
10
|
+
Requires-Python: >=3.10,<4.0.0
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -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
|
-
string_to_code/c_like_utils.py,sha256=
|
|
4
|
-
string_to_code/core.py,sha256=
|
|
3
|
+
string_to_code/c_like_utils.py,sha256=C_mEQbq8fy-pbsPrnLOTGrWFG6UpA8G2yE2LytFTQR0,2378
|
|
4
|
+
string_to_code/core.py,sha256=V3qLK_rWYcpeRWUw0WQyzesyYzphj53IMKkOmSgliFs,4336
|
|
5
5
|
string_to_code/string_to_code.py,sha256=q0IyBfeDeDI2SCwlBOM_hwHdBfF1YQ7gn642o6cHU94,1290
|
|
6
6
|
string_to_code/to_ada.py,sha256=gihr2fg0_cbH-oT2BamkF9GA1u4ktKWGiGFAzxTsDyY,2337
|
|
7
7
|
string_to_code/to_algol68.py,sha256=RPBQcA3UaEHtj0fxsscYpJy7ZpY-3ZSvChmaLzXb8n8,1707
|
|
@@ -17,8 +17,8 @@ string_to_code/to_nim.py,sha256=W74i6MRjQ5eYeatGyMwE-wYNEzN06l5oOXBv3lfbXgM,1534
|
|
|
17
17
|
string_to_code/to_pascal.py,sha256=ZwOJgi3saoNP2_H7ZWpQykPg8c-jP-L8eOw_Zz2q8uc,1922
|
|
18
18
|
string_to_code/to_python3.py,sha256=BJwjyhRB2IBOE3-xwkkMV3vZU-e2xreppYBKQeA1whg,1589
|
|
19
19
|
string_to_code/to_rust.py,sha256=hTCjlortLhR7FwsBgbrFRcwXpKWA6ed2UYnz1OK8R7I,1926
|
|
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=-B9dvRWUzHQh3-g7xGyK4yGY06l8EEDgaK0l3XMagLY,3775
|
|
21
|
+
string_to_code-0.2.12.dist-info/LICENSE,sha256=LQrcSkcUyN1FtFYDxWK05puxNN9o2q8PV-_2SwFDTWc,1068
|
|
22
|
+
string_to_code-0.2.12.dist-info/METADATA,sha256=Oneb_LYGixlQ3m5Bg39q9G3oET1ELf7K_PKEEwCOZnI,1857
|
|
23
|
+
string_to_code-0.2.12.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
24
|
+
string_to_code-0.2.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|