Mail Archives: djgpp/1998/07/07/04:00:39
In article <35a720ea DOT 2211979 AT news DOT Austria DOT EU DOT net>, sparhawk AT eunet DOT at (Gerhard
Gruber) writes:
|>Destination: blp01 AT uow DOT edu DOT au (Brett Porter)
|>From: Gruber Gerhard
|>Group: comp.os.msdos.djgpp
|>Date: Sun, 05 Jul 1998 03:03:04 GMT:
|>
|>Is you parser able to handle the continuation of sourclines via the "\"
|>character? I tried to figure that one out but I have problems defining a
|>syntax for lex.
|>
|>In C it is legal to write a line like this:
|>#i\
|>n\
|>c\
|>lude\
|><stdio\
|>.h>
|>
|>Dou you have any idea (or anybody else) how to solve this?
|>I checked out the sources for gcc but they wrote their own lexer so I can't
|>see anything there.
|>
This is not done by the compiler, but rather by the preprocessor; the compiler
would get the complete line #include <stdio.h>, (if this wasn't a preprocessor
line).
So it is no problem: for the preprocessor just write a pattern "\\\n" with no
action code, and this will eat up the line breaks. Note that the preprocessor
worksrecursively: if has to check the generated code if there are still more
preprocessor statements, and then handle these too. In this case, the file
stdio.h would be read in _by the preprocessor_.
Best regards
Michel
- Raw text -