User:Code-Analysis/sandbox
The grammar of the programming language can be considered either in wide terms that include exact specification of what is allowed and what is not allowed or in narrow terms that describe the formal grammar that is sutable for automatic creation of LR parsers. This article describes the formal grammar. For fine details please look at the main article on C++.
C++ 2003 Grammar
Formal gramar is presented in the Annex A of the standard. It consists of 3 major parts.
Lexical conventions
This parst of the grammar describes what is identifier, number, string, etc. Some of the rules are vague and contain human language like `each non-white-space character that cannot be...` or `any member of the source character set except ...`. Other rules contain lengthy enumerations that mention all letters of the English alphabet or names of all possible operations. This is why the table below contains serarate 2 lines for the number of fules.
Non terminals | 142 |
Grammar rules | 576 |
Parsing states (LR) | 14235 |
Grammar conflicts | 9337 |
Preprocessor Directives
Core Grammar
This part of the grammar describes the language itself; features like classes, functions, statements, expressions, etc. In particular it contans:
Non terminals | 142 |
Grammar rules | 576 |
Parsing states (LR) | 14235 |
Grammar conflicts | 9337 |
Reader can notice big number of grammar conflicts. Looking at these conflicts