Js2Py
Js2Py copied to clipboard
ClassDeclaration is not supported by ECMA 5.1
Evaluating functions work fine but as soon as Classes are introduced, js2py.eval_js
starts giving Error: js2py.internals.simplex.JsException: SyntaxError: Line 2: ClassDeclaration is not supported by ECMA 5.1
simple functions working:
When Classes are executed in Try It Yourself
area in http://piter.io/projects/js2py, it gives NotImplementedError
ClassDeclaration in python script:
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\pyjsparser\parser.py", line 3008, in parse
program = self.parseProgram()
File "C:\Python38\lib\site-packages\pyjsparser\parser.py", line 2974, in parseProgram
body = self.parseScriptBody()
File "C:\Python38\lib\site-packages\pyjsparser\parser.py", line 2963, in parseScriptBody
statement = self.parseStatementListItem()
File "C:\Python38\lib\site-packages\pyjsparser\parser.py", line 2107, in parseStatementListItem
raise Ecma51NotSupported('ClassDeclaration')
pyjsparser.std_nodes.Ecma51NotSupported: ClassDeclaration is not supported by ECMA 5.1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python38\lib\site-packages\js2py\evaljs.py", line 115, in eval_js
return e.eval(js)
File "C:\Python38\lib\site-packages\js2py\evaljs.py", line 204, in eval
self.execute(code, use_compilation_plan=use_compilation_plan)
File "C:\Python38\lib\site-packages\js2py\evaljs.py", line 199, in execute
exec (compiled, self._context)
File "<EvalJS snippet>", line 2, in <module>
File "C:\Python38\lib\site-packages\js2py\base.py", line 949, in __call__
return self.call(self.GlobalObject, args)
File "C:\Python38\lib\site-packages\js2py\base.py", line 1464, in call
return Js(self.code(*args))
File "C:\Python38\lib\site-packages\js2py\host\jseval.py", line 17, in Eval
py_code = translate_js(code.to_string().value, '')
File "C:\Python38\lib\site-packages\js2py\translators\translator.py", line 70, in translate_js
parsed = parse_fn(js)
File "C:\Python38\lib\site-packages\js2py\translators\translator.py", line 62, in pyjsparser_parse_fn
return parser.parse(code)
File "C:\Python38\lib\site-packages\pyjsparser\parser.py", line 3010, in parse
raise self.createError(self.lineNumber, self.lastIndex, unicode(e))
js2py.internals.simplex.JsException: SyntaxError: Line 2: ClassDeclaration is not supported by ECMA 5.1.
So, Just want to know if this will/can be supported in future releases ?
As, you have already mentioned multiple times that eval_js6
is extremely slow. For me its stuck since 5 minutes for the Animal class.
@hesoyamhh Is this solved? I got same error.
Any updates..? I'm also facing same error.
yep, I'm also getting the same error, I really hope this issue is being looked into.
There seems to be a eval_js6 function which does seem to do the trick.
I am having the same error. Any fixes?