lua-users home
lua-l archive

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


>E> This could very easily be done as a pre-processor written in Lua...
>You are right, though it has to handle string literals, comments and
>may have other problems.
>
>Here is a pre-alpha pre-processor that converts lua-scripts to
>python-like syntax (just removes extra 'end' keywords for now) and
>back. It is just a concept test and works only for very simple scripts
>(at least it works for its own source).

I have a simple utitily function that links with the lexer from the Lua core.
This would be the ideal tool for this task as all the hard parts are taken care
of automatically and in exactly the same way Lua does it.

I have posted versions of this code before in the list. If there's any interest
I can package it (after I finish the posix library!).

Alternatively, if the source code is well behaved, it can be done directly
in a lua_load callback, so that "end" would be inserted whenever the identation
backs down a level. Or something liek this.
--lhf