pseudo-lang / pseudo-python

a restricted python to javascript / c# / go / ruby compiler
MIT License
117 stars 14 forks source link

Support sys.stdin and sys.stdout #6

Open jzjsuper opened 8 years ago

jzjsuper commented 8 years ago
import sys
print(sys.stdin.readline())

Error:

Traceback (most recent call last):
  File "/usr/local/bin/pseudo-python", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/main.py", line 45, in main
    clj = yaml.dump(pseudo_python.translate(source))
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/__init__.py", line 5, in translate
    return pseudo_python.ast_translator.ASTTranslator(pseudo_python.parser.parse(source), source).translate()
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 104, in translate
    main = self._translate_main()
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 142, in _translate_main
    return self._translate_node(self.main)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 280, in _translate_node
    x = self._translate_node(n)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 656, in _translate_expr
    return self._translate_node(value)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 419, in _translate_call
    arg_nodes = self._translate_node(args)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 280, in _translate_node
    x = self._translate_node(n)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 423, in _translate_call
    func_node = self._translate_node(func, in_call=True)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 898, in _translate_attribute
    if value_node['name'] == 'sys' and attr == 'argv':
KeyError: 'name'
import sys
sys.stdout.write("123")

Error:

Traceback (most recent call last):
  File "/usr/local/bin/pseudo-python", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/main.py", line 45, in main
    clj = yaml.dump(pseudo_python.translate(source))
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/__init__.py", line 5, in translate
    return pseudo_python.ast_translator.ASTTranslator(pseudo_python.parser.parse(source), source).translate()
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 104, in translate
    main = self._translate_main()
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 142, in _translate_main
    return self._translate_node(self.main)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 280, in _translate_node
    x = self._translate_node(n)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 656, in _translate_expr
    return self._translate_node(value)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 423, in _translate_call
    func_node = self._translate_node(func, in_call=True)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 276, in _translate_node
    return getattr(self, '_translate_%s' % type(node).__name__.lower())(**fields)
  File "/usr/local/lib/python3.5/site-packages/pseudo_python/ast_translator.py", line 898, in _translate_attribute
    if value_node['name'] == 'sys' and attr == 'argv':
KeyError: 'name'
alehander92 commented 8 years ago

v0.4