Boost logo

Boost :

Subject: Re: [boost] [preprocessing] Feedback requested on a C99 preprocessor written in pure universal Python
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-03-06 20:46:06


On 06/03/2017 19:10, Edward Diener via Boost wrote:
> On 3/6/2017 5:45 AM, Niall Douglas via Boost wrote:
>> Those of you who watch reddit/r/cpp will know I've been working for the
>> past month on a pure Python implementation of a C99 conforming
>> preprocessor. I am pleased to be able to ask for Boost feedback on a
>> fairly high quality implementation:
>>
>> https://github.com/ned14/pcpp
>
> It would be nice, for the purpose of testing with Boost PP and Boost
> VMD, if somehow your preprocessor could somehow be plugged in to one of
> the compilers Boost supports, with VC++ being the most obvious choice
> because its preprocessor is not C++ standard conforming.

It's pretty straightforward in theory. pcpp can consume from stdin or a
file, and can output to stdout or a file, so it's easy to insert into a
sequence using the pipe operator (which works fine on Windows too).

An alternative is to simply feed its output to any compiler, pcpp marks
up the output with # lineno filepath exactly the same as a normal
preprocessor so the compiler can track the original source files. Those
should be passed through by any preprocessor unchanged, including MSVC's.

> There may be
> some other way of directly creating a toolset with your preprocessor in
> order to test it in Boost, but I am not knowledgeable enough with Boost
> Build to know how to do this. If you, or somebody else, could do this it
> would surely be welcome by me and probably by yourself.

I would be no more skilled than you at persuading Boost.Build to do
this. Even in cmake, it's tricky to inject a custom command inheriting
the current compiler flags i.e. all the -D's, -I's etc.

>> (and yes it is also a Python library as well as a command line tool, you
>> can find API reference docs at https://ned14.github.io/pcpp/)

Another big use case could be for debugging complex preprocessing
because it's very easy to hook in and introspect preprocessing as it is
being executed. But as I've mentioned, I've not tested it with really
complex preprocessor metaprogramming, getting it this far has already
taken me a month and I suspect my unemployment will be ending soon, so
my free time will return to nil. Still, it was a nice diversion away
from C++ and it has refreshed my Python skills very nicely.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk