|Using BTYACC to write C compiler J.R.Hall@dcs.warwick.ac.uk (Jules) (1996-05-08)|
|Re: Using BTYACC to write C compiler Scott.Nicol@infoadvn.com (1996-05-10)|
|Re: Using BTYACC to write C compiler firstname.lastname@example.org (1996-05-19)|
|From:||Scott.Nicol@infoadvn.com (Scott Nicol)|
|Date:||10 May 1996 01:32:00 -0400|
>I have started work with the ``ansiC.y'' and ``ansiC2.y'' grammars
>that were included in the BTYACC package, and wrote a lexical analyser
>for these using FLEX. My problem is that while trying to parse my
>assembler (which is an almost correct ANSI C program, and at least
>accepted as syntactically correct by every C compiler I've tried it
>on), the grammar freezes after a certain point, and I am unsure why.
You need to turn on Lex and YACC debugging. The Lex debugging output
should be obvious, but to read the YACC output, you need to have a
copy of y.output handy (generated using yacc -v). YACC will report
"State #, Token #". You can lookup the token in y.tab.h, and the
state in y.output. You will also see "reduce by #", which means that
you have just completed a rule - the reductions are also available in
Having to lookup stuff in y.output is a pain, and it can be confusing
at first. Some YACCs will let you interactively trace a running
grammar, so if you need to trace things often, this may be worth
BTW, I agree with the following comments from the moderator:
>[I'd start with lcc. There's a lot more to a C compiler than the parser.
I would add that, if you need C++, you may want to port g++ at some
point in the future. But start with lcc.
Scott Nicol email: email@example.com
Information Advantage, Inc.
Return to the
Search the comp.compilers archives again.