lua-users home
lua-l archive

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


DD is easy like Lua but actually it is partial copy from C style and little of Lua. I agree that function and table can make exact Lua code.

But I don't think, we could run the same DD files as it is. There are more complicated, we need to bother about fucntion call, include files, refines etc.  We would like to convert so that we could add rich UI libraries on top of generated code. Also we are not confident enough to execute a DD via Lua.
The advantages with the code generation is that, after code generation, we could hand code and fix the issues in the code generation. I am sure that we will not meet 100% of DD  to be auto-generated to Lua but we could fulfil using manual effort.

When we generate code, some portion we would use the steve advise that is call a function with argument which eventually to be added to Lua globals or index and also take a table like configuration.

--

Gopal

On Mon, Aug 22, 2011 at 4:07 PM, Axel Kittenberger <axkibe@gmail.com> wrote:
I'm with what steve said, in that case, I think in your case its much
simpler. Why write a parser at all? Just use Lua to parse a
programmable configfile for you! Thats what Lua originally was made
for.

This _is_ valid lua code, suppsing "WIDGET", "TILE", "TYPE",
"ELEMENTS" etc have been declared as functions:

WIDGET mywidget
{
   TITLE "My widget";
   TYPE WIDGET_TYPE;
   ELEMENTS
   {
       element1,
       element2,
       element3
   }
}

IMPORT  WIDGET mywidget
{
   REFINE widget_name{
       REDEFINE TITLE "Your widget";
   }
}

if YOUR_WIDGET_ALLOWED then
WIDGET yourwidget
{
   TITLE "Your widget";
   TYPE WIDGET_TYPE;
   ELEMENTS
   {
       element1,
       element2,
       element3
   }
}
endif

for x= 0, 8 do
  if  something_true then
      do_this(argument1, argument2);
  end
end


supports

do
   statements;
while(condition);

supports

while(condition)
   statements;
end