lua-users home
lua-l archive

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

Hello all,

I'm writting a parser in C (Lex & Yacc), to process a DSL similar to

    square square_name -x 20 -y 30 -height 20 -width 50
    circle circle_name -x 50 -y 60 -radius 100

After parsing this, I need to set a table with information about these
"objects" and pass it to a Lua script, so it can do anything with that
information, like drawing that on the screen.

My question is, from the parse level (a Yacc - .y - file) what is the
best way, conceptually, to pass it to Lua using a table?

I first thought about storing information in C structures, having a list
of them and after everything is stored, convert those structures to Lua
tables that can be used in a Lua script.

But after talking to a friend of mine (Eduardo Ochs -, I realized that I could simply put parsed
information in Lua tables using the Lua API (it is possible, right),
just after I got the token, yet at the .y file.  That would avoid the
hassle (or the fun?) of dealing with C code as early as possible.

What solution do you propose for this simple problem?


Silas Silva