Re: C compiler from scratch.

Detlef Meyer-Eltz <>
Wed, 15 Jul 2009 15:02:07 +0200

          From comp.compilers

Related articles
C compiler from scratch. (Vikranth) (2009-07-13)
Re: C compiler from scratch. (Detlef Meyer-Eltz) (2009-07-15)
Re: C compiler from scratch. (gopi) (2009-07-16)
Re: C compiler from scratch. (Hans-Peter Diettrich) (2009-07-18)
Re: C compiler from scratch. (2009-07-25)
| List of all articles for this month |

From: Detlef Meyer-Eltz <>
Newsgroups: comp.compilers
Date: Wed, 15 Jul 2009 15:02:07 +0200
Organization: Compilers Central
References: 09-07-024
Keywords: C, parse
Posted-Date: 15 Jul 2009 19:24:28 EDT

> Hi , I am looking for C grammar that is suitable for building a (hand
> written) compiler from scratch.Does the grammar provided in appendix
> of K&R book work? Or any alternatives please?

LL (1) grammars are suitable for handwritten parsers at best, because
every rule of the parser then can be considered as a specification for
the creation of a routine in your programming language.

The C parser at

nearly is an LL(1) adaption from the yacc grammar:

To read the grammar, you will have to install the free version of

There are two places, where a look-ahead was necessary. E.g. in the
statement rule:


The second look-ahead is in the rule "parameter_declaration". At this
places you have to find your own handwritten solutions.

If you will take C.ttp as copy for your project I would be pleased
very much if you would report me from your experiences.

Post a followup to this message

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