decalage2/ViperMonkey

API does not work

chenenjun opened this issue · 2 comments

Describe the bug
I checked the API documentation and wrote the code according to the above test cases, but I didn't get the expected results.
I try to use vmonkey.py directly. It works normally
sys: Ubuntu 14.04 LTS
e.g.

import vipermonkey
vba_code = '''
Dim m1, m2, m3 As String
m1 = "he" & "ll" & Chr(111) & " "
m2 = "w" & Chr(111) & "rl" & Chr(123 Xor 31)
m3 = "!!!"
m1 & m2 & m3
'''
print vipermonkey.eval(vba_code)

output:

Traceback (most recent call last):
  File "my_test.py", line 10, in <module>
    print vipermonkey.eval(vba_code)
  File "/home/ViperMonkey-master/vipermonkey/api.py", line 468, in eval
    return module.eval(context)
  File "/home/ViperMonkey-master/vipermonkey/api.py", line 401, in eval
    self.load_context(context)
  File "/home/ViperMonkey-master/vipermonkey/api.py", line 424, in load_context
    for name, _sub in self.obj.subs.items():
  File "/home/ViperMonkey-master/vipermonkey/api.py", line 451, in obj
    self._obj = _Module(str(self), 0, list(self.code_blocks))
  File "/home/ViperMonkey-master/vipermonkey/core/modules.py", line 113, in __init__
    self._handle_func_decls(tokens)
  File "/home/ViperMonkey-master/vipermonkey/core/modules.py", line 76, in _handle_func_decls
    token.accept(func_visitor)
TypeError: 'NoneType' object is not callable

Expected behavior
Make the APITutorial work as expected

Screenshots
pytest test_api.py
image
image

Indeed ViperMonkey has been modified a lot since the API documentation was written, and I'm not sure the API still works. Nowadays, ViperMonkey is only meant to be run as a script. I need to fix the documentation.

Thanks for the reply.
Looking forward to your update of the API documentation.