lua-users home
lua-l archive

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


Gang,

I need to implement a function (in either lua or C++) to parse some lua text to determine if it has a "main" function and if so, if that function has any executable lua code in it.

So, in other worlds, I'm going to parse text to search first for "function" and for each one found see if the next word is "main". If so, then skip past the open paren, any parameters and the close paren. That's all easy enuf...

Then comes the key part: scan until I find the "end" of the function, skipping comments and determining if there is other lua code there... I only need to determine true/false for the main function containing any executable code, so as soon as I find an keyword (if, while, do, local, etc) I can return true... if none found, and I hit "end" then return false.

The question I have is this: not having done any lua coding with patterns and the string functions, would this functionality be easier to code in Lua or on the C side?

Also, any suggestions, thoughts, caveats and the like are appreciated....

Thx,
Ando

-----------------------
Ando Sonenblick
SpriTec Software
www.spritec.com