GCC Parse Tree/Grammar Issues

Foolish Ewe foolishewe@hotmail.com
Tue Apr 15 03:51:00 GMT 2003


Hello all:

Thanks for the reply Neil.   I've never made a really large production 
compiler before
(compiler writing isn't an area I've done research or development in, 
although I've written
a few smaller compilers in grad school and created a few simple languages 
for my own use).
I wasn't really keen on rolling my own scanner, but I was curious about the 
design
decision.  My goal is to get parse tree output,  not reinvent the wheel.

Initially I had developed a simple FLEX/Bison tool using the grammar in K&R 
(proposed
ANSI standard edition, which shows my age I guess).  Similar to your 
suggestion, I
was planning on parsing the output of phase 4 of translation (as per
http://ou800doc.caldera.com/SDK_cprog/CLC_PhasesTranslation.html)
meaning that I compiled with the -P or -E flags turned on using gcc for 
initial preprocessing,
but even for source code that is ANSI C compatible, many headers assume a 
GCC dialect,
so this solution is clearly suboptimal.

Stephen Bosscher has helpfully pointed out that the SSA group might have
developed something that will meet my needs, but I'll need to do a little 
checking first
to see if it fits my needs.

>From: Neil Booth <neil@daikokuya.co.uk>
[deletia]
>Foolish Ewe wrote:-
>
> > 2) Am I correct that gcc uses an ad hoc scanner, I did not see a file 
>wiith
> > a .l extension
> >    in the directory and it looks like c-lex.c may be the scanner?  If 
>I'm
>
>Yes, it's hand coded.  If you can produce one that handles lexing in the
>same way as GCC, by passing the testsuite, and with all the diagnostics
>and correct source file locations, I would consider it, but I think
>you'll find that machine-generated scanners are not up to the job.
>Starting at stage 3 of the ISO phases of translation might be more
>realistic.
>
>The lexer is currently in cpplex.c (and partly cpptrad.c for traditional
>preprocessing), and is about to undergo a considerable rewrite over
>the next few weeks.  Whatever you do, it'll be worthwhile waiting for
>the dust to settle as the end result will be considerably cleaner.
>
>Neil.

Thanks again for the information:

Bill M. (Last name withheld  to prevent spamming)

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail



More information about the Gcc mailing list