[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C preprocessing in Lua
- From: "James Dennett" <james.dennett@...>
- Date: Fri, 14 Mar 2008 14:57:53 -0700
On Fri, Mar 14, 2008 at 2:48 PM, Eric Tetz <erictetz@gmail.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 need
> to be a full blown preprocessor, but it needs to handle lines
> continuation, comments, etc. and be able to resolve preprocessor
> conditionals properly.
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.
-- James