You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any way to get the parsed AST from a Lua script?
I am looking into making a visual editor for the lua scripts that are embedded into my app.
I'm still thinking through the idea, but I thought translating back and forth using the AST might be a good way to go.
@Yzupnick in the upcoming version of Lua, we have implemented our own parser that returns an AST, with functionality for manipulating the AST. I will let you know when it has been released, or you can test on main. I am still doing a lot of testing and cleanup, so use at your own caution!
Activity
davydog187 commentedon Aug 22, 2025
I've been wanting to expose the AST for a while.
I'm pretty sure this is possible but I haven't explored it yet.
davydog187 commentedon Feb 10, 2026
@Yzupnick in the upcoming version of Lua, we have implemented our own parser that returns an AST, with functionality for manipulating the AST. I will let you know when it has been released, or you can test on
main. I am still doing a lot of testing and cleanup, so use at your own caution!davydog187 commentedon Jun 1, 2026
@Yzupnick in 1.0.0 you will be able to do
To get the AST, and there are tools such as https://lua.hexdocs.pm/1.0.0-rc.0/Lua.AST.Walker.html for working with the AST. Let me know if you have any feedback
davydog187 commentedon Jun 15, 2026
Done —
Lua.Parser.parse_structured/1shipped in 1.0.0-rc.3 (#363). It returns{:ok, Chunk.t()} | {:error, [%Lua.Parser.Error{}]}, giving the parsed AST directly (with structured, JSON-serializable errors for tooling) — covering the visual-editor / AST round-trip use case.