boolangery / py-lua-parser

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

Wrong intent when calling to_lua_source() #24

Closed penguinol closed 2 years ago

penguinol commented 2 years ago

for example, a lua file like:

local a = 0
if a == 0 then
    if a == 1 then
        if a == 2 then
            if a == 3 then

            end
        end
    end
end

I loaded the lua source by ast, and then rewrite the ast to source.

lua_ast = ast.parse(content)
tree = ast.parse(content)
print(ast.to_lua_source(tree))

the output is like

local a = 0
if a == 0 then
  if a == 1 then
      if a == 2 then
            if a == 3 then

            else

            end
      else

      end
  else

  end
else

end