ANSI C Yacc grammar
20 Oct 2001 21:52:46 -0400

          From comp.compilers

Related articles
ANSI C Yacc grammar (2001-10-20)
Re: ANSI C Yacc grammar (2001-10-23)
Re: ANSI C Yacc grammar (Axel Kittenberger) (2001-10-23)
Re: ANSI C Yacc grammar (2001-10-27)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 20 Oct 2001 21:52:46 -0400
Organization: ATO-DLO
Keywords: C, parse, question, comment
Posted-Date: 20 Oct 2001 21:52:46 EDT


I would like to make some kind of a translator for the C language, and
therefore I have looked at the C grammar in the K&R book and a yacc
grammar of Jutta Degener on:

I noticed that the above mentioned grammars are not very restrictive,
as they accept input which is not legal ANSI C, like:

register int main()
return 1;

int main(int, int *, int)
return 2;

int main(char a[][][])

Why is this input accepted ? Is it not possible to write a grammar
which is more close to the ANSI C syntax ? I understand that a yacc
based grammmer could not do things like type checking and parameter
checking etc, but a better syntax checking seems possible to me.

Gerwoud Otten.
[I find that I can generate much better error messages by accepting
a larger language in the parser and then rejecting the excess later.

Post a followup to this message

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