lua-users home
lua-l archive

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

Hi lhf, a suddenly idea appears to me. As we already had some lua functions 
like "loadstring" which could compile the lua codes to byte codes directly 
on the fly. But why don't we also provide some c level functions further like:

    load_lua_code_to_ast: return corresponding ast table (the ast described by
    linked lua tables, and users could modify it as their wishes)

    translate_ast_to_lua_code: translate the ast table to lua source code again

    execute_ast: execute the ast directly

Of course some other library already done the equivalent job, but I think this job 
should be done by lua itself as many nowadays language provide their own parser 
which could parse themself to certain AST(like golang) and it would be more stable 
and performant.

We could say:

    Lua: The code is data, the data is code (: we could go even further than lisp :)

On Wed, Jun 14, 2017 at 7:19 AM, Luiz Henrique de Figueiredo <> wrote:
> the DSL I want to parse is just a subset of lua language,
> and the goal is to implement a source-to-source translator.

 From Lua to what?