[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Two small questions/comments
- From: "Matt Holmes" <kerion@...>
- Date: Mon, 24 Sep 2001 15:05:41 -0400
> See http://www.lua.org/history.html (subsection "Lua version 3").
> See lua/test/pp.lua
A good point is made in that sub-section, but a preprocessor is not
something terribly difficult to offer as a an extension or wrapper library.
If enough interest is really there for a preprocessor, I will clean up my
current implementation of one and distribute it as a C++ class for all to
use. I would like to, at some point, implement full macro expansion, but I
don't need it right now and would only implement when I did decide it was
useful in the context of Templar. Currently the following tokens are useable
in my preprocessor:
import <file> - equiv of C/C++ include. This is a "hard" import, or
basically a programmatic paste
define <macro> <value> - same as C/C++ macro definition, you can define
simple, single line chunks of Lua code this way. You can of course define
constants this way as well, as the expansion is literal, no extra parsing is
done (not even for other macros, which is something else I need to fix).
Macros with no values are supported as well (this gives you the ability to
define a macro simply to have it defined, such as @define _DEBUG). My next
enhancement will be multi-line defines. The only thing missing for full
macro expansion is parameterized macros.
if <macro> - conditional to determine of <macro> is defined, if so, then
conditional include the next block of code for compilation. If <macro> is
not defined, then the block of code that follows it is never even presented
to the Lua interpreter (true conditional compilation)
ifnot <macro> - conditional to determine if <macro> is NOT defined. Same
behavior as if.
else - Self explanatory
Anything else that is preceded by the PREPROC_SYMBOL (@ in my case), is
considered "meta-data". This is only useful for my implementation, and it
would likely be removed in any wrapper class I released.
I am currently working on this (as in, every 5 minutes I do a new build),
but if enough interest is there (aka more then one person), I will gladly
post a zip of the code on a website. It will be fully ISO C++ compliant
using the STL. I only have Win32/VC++ available to compile it under, but it
should compile under any near standard C++ compiler with an up to date
implementation of the STL.
Matt "Kerion" Holmes