Is there a standard C++ grammar?

Lazer picture Lazer · May 17, 2010 · Viewed 17k times · Source

Does the standard specify the official C++ grammar?

I searched, but did not find it anywhere.

Also, I wish to read a bit about C++ grammar in detail, like which category of grammars it falls in, etc. Any links pointing me in the right direction would be helpful.

By category, I mean

Click to enlarge taken from here.

Answer

James McNellis picture James McNellis · May 17, 2010

Yes, it does.

The grammar is described in detail throughout the standard and is summarized in Appendix A: Grammar Summary (it's Appendix A in both the C++03 standard and the C++0x final committee draft).

You can purchase the C++03 standard or you can download the C++0x FCD (it's document n3092 on that page).

To answer the "what category is it in?" question, the C++ grammar is not context-free (also see the questions linked in answers to that question; they have additional examples of issues related to the C++ grammar and parsing C++).