boolangery / py-lua-parser

A Lua parser and AST builder written in Python.
MIT License
117 stars 36 forks source link

Cant walk the ast tree if lua file has semicolon(;) or repeat until loop and multiple args(...) #9

Closed TimKaptan closed 4 years ago

TimKaptan commented 4 years ago

Screenshot_9

When i try to walk the ast tree of a lua file which has semicolon or repeat until loop or varargs, lib throws an exception.

gstggsstt commented 4 years ago

I fixed this problem with following code

import luaparser
from luaparser import ast
from luaparser import astnodes

def visit_Varargs(self, node): pass
luaparser.utils.visitor._methods[('luaparser.ast.WalkVisitor', luaparser.astnodes.Varargs)] = visit_Varargs
def visit_SemiColon(self, node): pass
luaparser.utils.visitor._methods[('luaparser.ast.WalkVisitor', luaparser.astnodes.SemiColon)] = visit_SemiColon
def visit_Repeat(self, node):
    self._nodes.append(node)
    self.visit(node.body)
    self.visit(node.test)
luaparser.utils.visitor._methods[('luaparser.ast.WalkVisitor', luaparser.astnodes.Repeat)] = visit_Repeat
clouds56 commented 3 years ago

Thanks for fixing. Is there any plan for release this?

boolangery commented 3 years ago

I just made a new release :) https://github.com/boolangery/py-lua-parser/releases/tag/3.0.0