MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / PrettyUnparser

Class PrettyUnparser

scratchattach/editor/code_translation/parse.py:35–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 return reconstructor.reconstruct(tree)
34
35class PrettyUnparser(Transformer):
36 INDENT_STRING = " "
37
38 @classmethod
39 def _indent(cls, text):
40 if not text:
41 return ""
42 return "\n".join(cls.INDENT_STRING + line for line in text.splitlines())
43
44 def PARAM_NAME(self, token):
45 return token.value
46
47 def BLOCK_NAME(self, token):
48 return token.value
49
50 def EVENT(self, token):
51 return token.value
52
53 def CONTROL_BLOCK_NAME(self, token):
54 return token.value
55
56 def _PREPROC_INSTR_CONTENT(self, token):
57 return token.value
58
59 def _COMMMENT_CONTENT(self, token):
60 return token.value
61
62 @v_args(inline=True)
63 def hat(self, child):
64 return child
65
66 @v_args(inline=True)
67 def param(self, child):
68 return child
69
70 @v_args(inline=True)
71 def value_param(self, name):
72 return name
73
74 @v_args(inline=True)
75 def bool_param(self, name):
76 return f"<{name}>"
77
78 @v_args(inline=True)
79 def event_hat(self, event_name):
80 return f"when ({event_name})"
81
82 def block_hat(self, items):
83 name, *params = items
84 params_str = ", ".join(params)
85 return f"custom_block {name} ({params_str})"
86
87 @v_args(inline=True)
88 def PREPROC_INSTR(self, content):
89 return f"{content}"
90
91 @v_args(inline=True)
92 def COMMMENT(self, content):

Callers 1

pretty_unparseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected