Related articles |
---|
ANSI C Yacc grammar g.w.otten@ato.dlo.nl (2001-10-20) |
Re: ANSI C Yacc grammar GOLDParser@DevinCook.com (2001-10-23) |
Re: ANSI C Yacc grammar axel@dtone.org (Axel Kittenberger) (2001-10-23) |
Re: ANSI C Yacc grammar g.w.otten@ato.dlo.nl (2001-10-27) |
From: | g.w.otten@ato.dlo.nl |
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 |
Hello,
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:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
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.
Greetings,
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.
-John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.