KoD 1.7.7
- fix di routine ai canali/server\n\n
This commit is contained in:
@@ -55,16 +55,19 @@ def dbg(x):
|
||||
"""does nothing, legacy dummy function"""
|
||||
return ''
|
||||
|
||||
# Another way of doing that would be with my auto esprima translation but its much slower:
|
||||
# parsed = esprima.parse(js).to_dict()
|
||||
def pyjsparser_parse_fn(code):
|
||||
parser = pyjsparser.PyJsParser()
|
||||
return parser.parse(code)
|
||||
|
||||
def translate_js(js, HEADER=DEFAULT_HEADER, use_compilation_plan=False):
|
||||
def translate_js(js, HEADER=DEFAULT_HEADER, use_compilation_plan=False, parse_fn=pyjsparser_parse_fn):
|
||||
"""js has to be a javascript source code.
|
||||
returns equivalent python code."""
|
||||
if use_compilation_plan and not '//' in js and not '/*' in js:
|
||||
return translate_js_with_compilation_plan(js, HEADER=HEADER)
|
||||
parser = pyjsparser.PyJsParser()
|
||||
parsed = parser.parse(js) # js to esprima syntax tree
|
||||
# Another way of doing that would be with my auto esprima translation but its much slower and causes import problems:
|
||||
# parsed = esprima.parse(js).to_dict()
|
||||
|
||||
parsed = parse_fn(js)
|
||||
translating_nodes.clean_stacks()
|
||||
return HEADER + translating_nodes.trans(
|
||||
parsed) # syntax tree to python code
|
||||
|
||||
Reference in New Issue
Block a user