lua-users home
lua-l archive

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

Luiz Henrique de Figueiredo kirjoitti 5.11.2008 kello 14:59:

I am sorry in advance if my question seems stupid ;-) but I just would
like to better understand the best way to proceed in order to try to
solve a problem.

Perhaps you could tell us what problem you're trying to solve.

Lua is a language and a very fast virtual machine... I would like to
try to reuse the efficient virtual machine built-into lua but using a
very different syntax (and not the lua language).

You can replace the parsing modules (llex.c, lparser.c, lcode.c) but
you'll need to understand how they work. If you want to use different
tokens but the same abstract syntax, then you can replace llex.c,
which is not hard to do (and you can probably reuse many bits in llex.c).

If you don't want to fiddle with the internals of Lua, try metalua and
luasub for instance.

As Luiz writes, you could use Metalua or luaSub to parse some other language's syntax and transform it into Lua. But this would only work for relatively simple configuration-language kind of cases.

Lua is a lot about the metamethods etc. that are there in the background. In the long run I doubt making a separate syntax would be worthwhile. But once you identify the things in Lua you want to avoid, these tools can rather easily allow you to go around those corners.

LuaSub has not gotten much action since its release, but it certainly is one of the projects I intend to keep alive for a long time. It has numerous samples about how to fiddle with Lua's syntax.