Related articles |
---|
C compiler from scratch. vikranthit@gmail.com (Vikranth) (2009-07-13) |
Re: C compiler from scratch. Meyer-Eltz@t-online.de (Detlef Meyer-Eltz) (2009-07-15) |
Re: C compiler from scratch. gopi.onthemove@gmail.com (gopi) (2009-07-16) |
Re: C compiler from scratch. DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-07-18) |
Re: C compiler from scratch. s_dubrovich@yahoo.com (2009-07-25) |
From: | Detlef Meyer-Eltz <Meyer-Eltz@t-online.de> |
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.
http://www.texttransformer.com/tthelp/introduction_prodsasfuncs.htm
The C parser at
http://www.texttransformer.org/c_en.html
nearly is an LL(1) adaption from the yacc grammar:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
To read the grammar, you will have to install the free version of
TextTransformer:
http://www.texttransformer.com/downloads/TetraInstall.exe
There are two places, where a look-ahead was necessary. E.g. in the
statement rule:
IF(labeled_statement())
labeled_statement
ELSE
...
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.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.