lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sat, Jan 30, 2010 at 3:06 PM, Luiz Henrique de Figueiredo <> wrote:
> This is easily used for round-tripping (if your Lua parser handles scopes,
> variables aliasing etc. reasonably well)

Are you using your own Lua parser? Why not the core parser?

We're using metalua, because it works well for that kind of purpose, and obviously I'm quite proficient with it.

Using the core parser would probably have been difficult:

- it's in C, so fiddling with it involves a lot of low level scary details. I mean, we're already running Eclipse anyway, so we don't care about the core parser's thriftiness in CPU and RAM usage!

- the core parser produces bytecode on-the-fly. We want trees, and we want to easily navigate back and forth in them. That's basically what metalua's mlp.ast_of_luafile() provides with a single function call, and the result is an easily handled set of nested Lua tables.

- metalua already has the libraries useful for that kind of job: "find the creation statement and all the occurrences of this variable, without being fooled by scopes or shadowing variables"; "iterate on method invocations which satisfy an arbitrary predicate"; "extract the source code of this subtree"; etc.