string-to-code 0.2.9__tar.gz → 0.2.11__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.
- {string_to_code-0.2.9 → string_to_code-0.2.11}/PKG-INFO +1 -1
- {string_to_code-0.2.9 → string_to_code-0.2.11}/pyproject.toml +1 -1
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/c_like_utils.py +1 -1
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/core.py +3 -3
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_ada.py +4 -4
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_algol68.py +3 -3
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/utils.py +6 -2
- {string_to_code-0.2.9 → string_to_code-0.2.11}/LICENSE +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/README.md +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/__init__.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/string_to_code.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_ballerina.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_bash.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_c.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_cobol.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_cpp.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_haskell.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_java.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_lisp.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_nim.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_pascal.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_python3.py +0 -0
- {string_to_code-0.2.9 → string_to_code-0.2.11}/string_to_code/to_rust.py +0 -0
|
@@ -57,7 +57,7 @@ def get_merge_to_full_function(in_function_prefix):
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
def get_main_call_fun(in_call_function_or_atom):
|
|
60
|
-
"""returns function
|
|
60
|
+
"""returns function returning code of main C or C++ function"""
|
|
61
61
|
|
|
62
62
|
def _main_call(in_initial_call, **kwargs):
|
|
63
63
|
initial_call_str = (
|
|
@@ -33,7 +33,7 @@ SimpleFunctions: typing.TypeAlias = typing.List[SimpleFunction]
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
def str_pieces(in_str: str, in_pieces_len: typing.List[int]) -> Strings:
|
|
36
|
-
"""returns in_str
|
|
36
|
+
"""returns in_str split into pieces of lengths as in in_pieces_len"""
|
|
37
37
|
assert all(_ > 0 for _ in in_pieces_len)
|
|
38
38
|
assert sum(in_pieces_len) == len(in_str)
|
|
39
39
|
cur_str = in_str
|
|
@@ -74,7 +74,7 @@ def _interesting_random_split(in_str: str) -> Strings:
|
|
|
74
74
|
def get_function_namer(
|
|
75
75
|
in_name_prefix: str = "f_",
|
|
76
76
|
) -> collections.abc.Callable[[int], str]:
|
|
77
|
-
"""returns a
|
|
77
|
+
"""returns a default function namer"""
|
|
78
78
|
|
|
79
79
|
def _inner(in_id: int) -> str:
|
|
80
80
|
return in_name_prefix + str(in_id)
|
|
@@ -147,5 +147,5 @@ class PrinterProgram:
|
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
def get_printer_program(in_str: str) -> PrinterProgram:
|
|
150
|
-
"""returns a PrinterProgram object
|
|
150
|
+
"""returns a PrinterProgram object displaying in_str"""
|
|
151
151
|
return PrinterProgram(*_prepare_printer_program(in_str))
|
|
@@ -34,7 +34,7 @@ _body_to_str = utils.get_body_to_str(
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def _merge_to_full_function(in_function_name, in_function_body):
|
|
37
|
+
def _merge_to_full_function(in_function_name: str, in_function_body: str) -> str:
|
|
38
38
|
return "\n".join(
|
|
39
39
|
[
|
|
40
40
|
f" procedure {in_function_name} is",
|
|
@@ -50,7 +50,7 @@ _function_to_code = utils.get_function_to_code(
|
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def default_program_name():
|
|
53
|
+
def default_program_name() -> str:
|
|
54
54
|
"""returns the default program name used by the proc function"""
|
|
55
55
|
return "Main"
|
|
56
56
|
|
|
@@ -58,13 +58,13 @@ def default_program_name():
|
|
|
58
58
|
_MAIN_NULL_CALL = " " + _NULL_CALL + "\n"
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def _main_call_to_code(in_initial_call, **kwargs):
|
|
61
|
+
def _main_call_to_code(in_initial_call: core.InitialCall, **kwargs) -> str:
|
|
62
62
|
if in_initial_call:
|
|
63
63
|
return " " + _call_function_or_atom(in_initial_call, **kwargs) + "\n"
|
|
64
64
|
return _MAIN_NULL_CALL
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
def _join_to_final(main_call, function_definitions, **kwargs):
|
|
67
|
+
def _join_to_final(main_call: str, function_definitions: list[str], **kwargs) -> str:
|
|
68
68
|
function_definitions_str = "\n".join(function_definitions)
|
|
69
69
|
if function_definitions_str:
|
|
70
70
|
function_definitions_str += "\n"
|
|
@@ -29,7 +29,7 @@ _call_function_or_atom = utils.get_call_function_or_atom(
|
|
|
29
29
|
_body_to_str = utils.get_body_to_str("\n", " ", _call_function_or_atom, "", "")
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def _merge_to_full_function(in_function_name, in_function_body):
|
|
32
|
+
def _merge_to_full_function(in_function_name: str, in_function_body: str) -> str:
|
|
33
33
|
body_str = ""
|
|
34
34
|
if in_function_body:
|
|
35
35
|
assert in_function_body[-1] == ";"
|
|
@@ -42,7 +42,7 @@ _function_to_code = utils.get_function_to_code(
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
def _main_call_to_code(in_initial_call, **kwargs):
|
|
45
|
+
def _main_call_to_code(in_initial_call: core.InitialCall, **kwargs) -> str:
|
|
46
46
|
if in_initial_call is None:
|
|
47
47
|
return 'print("")'
|
|
48
48
|
res = _call_function_or_atom(in_initial_call, **kwargs)
|
|
@@ -50,7 +50,7 @@ def _main_call_to_code(in_initial_call, **kwargs):
|
|
|
50
50
|
return res[:-1]
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def _join_to_final(main_call, function_definitions, **_kwargs):
|
|
53
|
+
def _join_to_final(main_call: str, function_definitions: list[str], **_kwargs) -> str:
|
|
54
54
|
assert main_call[-1] != "\n"
|
|
55
55
|
return "\n\n".join(function_definitions + [main_call + "\n"])
|
|
56
56
|
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
utilities for to_some_language modules
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import typing
|
|
5
6
|
from . import core
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def get_function_name_fun(in_prefix: str = "fun_"):
|
|
9
|
-
"""returns a function
|
|
10
|
+
"""returns a function returning a function name based on id"""
|
|
10
11
|
|
|
11
12
|
def _get_function_name(in_function_id: int, **kwargs) -> str:
|
|
12
13
|
return kwargs.get("function_id_to_name", core.get_function_namer(in_prefix))(
|
|
@@ -26,13 +27,16 @@ def get_function_call_str_fun(in_get_function_name, in_prefix: str, in_postfix:
|
|
|
26
27
|
return _function_call_str
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
def get_call_function_or_atom(
|
|
30
|
+
def get_call_function_or_atom(
|
|
31
|
+
in_atom_to_code: typing.Callable[[core.Atom], str], in_function_call_str
|
|
32
|
+
):
|
|
30
33
|
"""
|
|
31
34
|
returns the function call_function_or_atom returning a string
|
|
32
35
|
representing a function call or displayng given atom
|
|
33
36
|
"""
|
|
34
37
|
|
|
35
38
|
def _inner(in_data: core.CalledListEntry, **kwargs) -> str:
|
|
39
|
+
assert in_data is not None
|
|
36
40
|
if isinstance(in_data, core.Atom):
|
|
37
41
|
return in_atom_to_code(in_data)
|
|
38
42
|
assert isinstance(in_data, int)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|