lua-users home
lua-l archive

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

I am in the process of replacing a home-grown, minimally functional internal scripting language with Lua.  Linking the application to Lua and passing data back and forth is very easy.  However, I have a set of existing user scripts that I would like to be able to process for backwards-compatibility.

Obviously, I could simply retain the existing script engine and run it side-by-side with Lua, but I was hoping to jettison the entire thing forever so that I would not have to maintain it.

The original syntax was very tiny, with only a few operations (some math and numerical comparison test), and was only really meant to allow a particular operation in the application to be repeated some set number of times.  However, there are some syntax differences that might make it difficult to emulate in Lua.  Here is an example:

x=1.0;WHILE x<4.0 DO

And that's about it in a nutshell.  If I can somehow map this functionality to Lua, I'm finished with the backwards-compatibility stage and I can move on to new functionality.

The "StartTest" and "Stop" are C call-backs to the application, and pose no problem.

The "SetDuration" would also be easy to deal with if it weren't for the square-bracket notation.  This is treated as a function call in the original language, but I guess it gets handled as a table lookup in Lua.  Is it possible to overload the table lookup so that it gets passed back to C so I can just trigger the function call?

The "WHILE" and "DO" are the same as Lua, except for the case of the letters.  Is there any way to alias WHILE and DO to the correct calls?  Along the same lines, I would need to have the "OD" treated as "end".

Any pointers (or URL's to examples) would be a huge help.