|
Joshua Jensen wrote:
I was trying to use lpeg to put together a C preprocessor
Though one could, I think the larger question is why. CPP has substantial limitations (e.g. looping and data structures). However, if you're given Lua, it's relatively simple to reuse the full power of Lua without the lpeg dependency: http://lua-users.org/wiki/SlightlyLessSimpleLuaPreprocessor . What you may (or may not) still want is the C language tokenization as applied in CPP so that macros appear like regular identifiers. A questionably useful example in C++ is
#define private publicGoing beyond this, one of the things I've thought about was allowing C to be metaprogrammed in Lua. This involves the parsing (not just lexing) of C from Lua so that Lua has access to the C parse tree.