PythonJS / PythonJS

PythonJS development has moved to Rusthon
https://github.com/rusthon/Rusthon
Other
886 stars 93 forks source link

Help getting started with --lua #158

Closed MayamaTakeshi closed 9 years ago

MayamaTakeshi commented 9 years ago

I am experimenting translating a small python fragment to lua doing this:

$ echo "print 'hello %(name)s' % {'name': 'world'}" | ./translator.py --lua a.py 
print(__sprintf("hello %(name)s", __jsdict({{"name", "world"}})))

But how do I create the lua modules that implement sprintf and jsdict? I can see __sprintf can be found in runtime/lua_builtins.py Should I translate this to lua? I tried but translation failed:

$ ./translator.py --lua runtime/lua_builtins.py
Traceback (most recent call last):
  File "./translator.py", line 138, in <module>
    command()
  File "./translator.py", line 130, in command
    js = main(data, module_path=mpath)
  File "./translator.py", line 50, in main
    a = python_to_pythonjs(script, lua=True, module_path=module_path)
  File "/mnt/oldharddisk/takeshi_extra/src/git/PythonJS/pythonjs/python_to_pythonjs.py", line 4057, in main
    module_path = module_path
  File "/mnt/oldharddisk/takeshi_extra/src/git/PythonJS/pythonjs/python_to_pythonjs.py", line 192, in __init__
    source = typedpython.transform_source( source )
  File "/mnt/oldharddisk/takeshi_extra/src/git/PythonJS/pythonjs/typedpython.py", line 65, in transform_source
    assert ''.join(a[-3:])=='map'
AssertionError

What about __jsdict?

MayamaTakeshi commented 9 years ago

Thanks.