[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: C preprocessing in Lua
- From: Asko Kauppi <askok@...>
- Date: Sat, 15 Mar 2008 00:05:56 +0200
Hamster is a Lua build system, which does dependency checking
However, it simply looks for any #include's and naively thinks they
all affect the source. Are you sure this wouldn't be enough for you as
Maybe just run the files through cpp, then look for the #includes that
James Dennett kirjoitti 14.3.2008 kello 23:57:
On Fri, Mar 14, 2008 at 2:48 PM, Eric Tetz <email@example.com> wrote:
I'm writing a tool which needs (as one stage) to resolve the header
dependencies of C source modules. Currently we are using Opus Make
MKMF.EXE to parse the sources and generates dependency lists. I would
*like* to roll this part of the process into the main tool, which is
written in Lua.
Has anyone written something like this, or know of a module (in Lua,
usable by Lua, translatable into Lua) which does this? It doesn't
to be a full blown preprocessor, but it needs to handle lines
continuation, comments, etc. and be able to resolve preprocessor
That covers most of the preprocessor: conditionals need macro
expansion and expression evaluation, and those require tokenization,
comment handling, etc.
Boost has a preprocessor implementation in library form if you don't
mind it being in C++ and having significant dependencies. I have one
too, though it's not been tested except by me; it's also in C++. Both
are fairly modular/flexible.
Writing such a thing in Lua would take, I'd expect, thousands rather
than hundreds of lines of code. Performance may or may not be an
issue, but I'd think it easier to pick up an implementation off the
shelf and wrap it in Lua.