[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Class pre-processor
- From: "Andre de Leiradella" <leiradella@...>
- Date: Sun, 22 Jun 2003 21:15:23 -0300
I finish the work with the class pre-processor. It turned out in something a
little bigger than I first expected... It's a input-only stream system that
allows Lua files to be loaded and executed from various sources and formats:
. Reads data from files and memory;
. Decompresses data in .gz or .bz2 formats on-the-fly;
. Bufferizes input streams (I don't know a good use for this one yet);
. Pre-process the input stream before handling it to Lua.
The pre-processing, that started it all, changes the following constructs in
the source file:
. "@id": field access;
. "@id(parameters)": method call;
. "@@id(parameters)": inherited method call.
The changes are controled by three format strings, one for each construct.
The format strings are passed unchanged to Lua with the exception of:
. "%i": changed to the id;
. "%p": changed to the parameters;
. "%P": changes to the parameters with a leading comma, if the parameter
list isn't empty.
As a future work I intend to write a pre-processor like C pre-processors
with include, define, ifdef etc., maybe including a regex system to give the
user more options than he/she have with macros only, and a few more source
readers (file descriptors and pipes). When it's safe to use the lua state
during a read, I'll add a lua reader that will read bytes calling a lua
The library comes with a small demo and with instructions on how to use it.
Please send bugs directly to me.
Andre de Leiradella