help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C preprocessor


From: Giacinto Cifelli
Subject: Re: C preprocessor
Date: Fri, 14 Aug 2020 05:01:38 +0200

Hi Ervin,

thank you for your answer :)

in both projects the lexer is handwritten, and it doesn't seem to build an AST.

I have found meanwhile something that goes more in the direction I am
interested in:
    
https://nyuscholars.nyu.edu/en/publications/superc-parsing-all-of-c-by-taming-the-preprocessor-2
the source code is embedded in a larger tool (and also the lexer style
is quite interesting):
    https://github.com/paulgazz/xtc

Nevertheless, to come back to my original point, I am interested in
building an AST for macro languages.
Tricky because it requires interpretation and expansion. Macro
languages are easy to expand, but not so easy to reconstruct the
original from the AST.
Maybe this is what I am looking for: build an AST such that one can
extract the resulting text and the original one from it.

Thank you,
Giacinto


On Thu, Aug 13, 2020 at 11:35 PM Ervin Hegedüs <airween@gmail.com> wrote:
>
> Hi Giacinto,
>
>
> may be this will not the exact answer what you're waiting for,
> but perhaps will help... :)
>
> On Thu, Aug 13, 2020 at 07:49:52AM +0200, Giacinto Cifelli wrote:
> > Hi all,
> >
> > I am wondering if it is possible to interpret a c-preprocessor (the second
> > preprocessor, not the one expanding trigrams and removing "\\\n") or an m4
> > grammar through bison, and in case if it has already been done.
>
> There is a very old project, called mccp:
>
> http://mcpp.sourceforge.net/
>
> I'm afraid that's not active but may be useful. Eg. that has a
> very good background documentation:
>
> https://kumisystems.dl.sourceforge.net/project/mcpp/mcpp/V.2.7.2/mcpp-summary-272.pdf
>
> Note that IMHO it doesn't use any LR or LALR parser, but I
> didn't jumped into the source...
>
> The another project - just found now - which could be interest
> for you is this:
>
> https://github.com/facebookarchive/warp
>
> It was written in D, but there is a lexer, which can helps you.
>
>
> Hope this helps.
>
>
>
> a.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]