Context-free grammar for C

limp_chimp picture limp_chimp · Mar 19, 2013 · Viewed 21.1k times · Source

I'm working on a parser for C. I'm trying to find a list of all of the context-free derivations for C. Ideally it would be in BNF or similar. I'm sure such a thing is out there, but googling around hasn't given me much.

Reading the source code for existing parsers/compilers has proven to be far more confusing than helpful, as most that I've found are much more ambitious and complicated than the one I'm building.

Answer

xji picture xji · Nov 21, 2014

This is an ANSI-C grammar, updated to C11 standard. Should serve your purpose.

http://www.quut.com/c/ANSI-C-grammar-y.html