Re: Preprocessor suggestions (Ralph Corderoy)
20 Sep 2001 00:21:40 -0400

          From comp.compilers

Related articles
Preprocessor suggestions (2001-09-16)
Re: Preprocessor suggestions (2001-09-20)
Re: Preprocessor suggestions (Olivier Ridoux) (2001-09-20)
| List of all articles for this month |

From: (Ralph Corderoy)
Newsgroups: comp.compilers
Date: 20 Sep 2001 00:21:40 -0400
Organization: InputPlus Ltd.
References: 01-09-066
Keywords: C
Posted-Date: 20 Sep 2001 00:21:40 EDT


> > I'd like to start a translator program from C to a much less
> > expressive language. My first step would be to modify the c
> > preprocessor so that it doesnt swallow up the comments.

Does doing this help or are you just trying a simple task first?

> > Anyone see a problem with trying to do this.
> Leaving comments in the preprocessed code is easy enough, but keeping
> comments in a parser is surprisingly tricky.

I'm not sure it was clear that comments are required in the compiler's
parser, although it's a reasonable assumption. If not, the
preprocessor could leave them in and the compiler's lexer drop them.

The C preprocessor would still need knowledge of them in macro
processing AFAICS.

        int debug_hashtable;
        int numbucket;
        int hash;

        #define DEBUG(flag, i) \
                if (debug_ ## flag) { \
                        printf("%d\n", (i)); \

        void foo(void)
                DEBUG(hashtable, numbucket);
                DEBUG(/* FIXME: needs its own flag. */ hashtable, hash);


You wouldn't want `debug_/*' being tested in the second case.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.