Skip to content

Latest commit

 

History

History
529 lines (383 loc) · 35.9 KB

File metadata and controls

529 lines (383 loc) · 35.9 KB

C++ Grammar

Table of contents

  1. Lexical
  2. Expressions
  3. Statements
  4. Declarations
  5. Declarators
  6. Classes
  7. Derived classes
  8. Special member functions
  9. Overloading
  10. Templates
  11. Exception handling
  12. Index of rules

Lexical

token

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
keyword ✔️ ✔️ ✔️ ✔️
punctuator ✔️ ✔️ ✔️ ✔️
identifier ✔️ ✔️ ✔️ ✔️

keyword

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
alignas ✔️ ✔️ ✔️
alignof ✔️ ✔️ ✔️
and ✔️ ✔️ ✔️ ✔️
and_eq ✔️ ✔️ ✔️ ✔️
asm ✔️ ✔️ ✔️ ✔️
auto ✔️ ✔️ ✔️ ✔️
bitand ✔️ ✔️ ✔️ ✔️
bitor ✔️ ✔️ ✔️ ✔️
bool ✔️ ✔️ ✔️ ✔️
break ✔️ ✔️ ✔️ ✔️
case ✔️ ✔️ ✔️ ✔️
catch ✔️ ✔️ ✔️ ✔️
char ✔️ ✔️ ✔️ ✔️
char16_t ✔️ ✔️ ✔️
char32_t ✔️ ✔️ ✔️
class ✔️ ✔️ ✔️ ✔️
compl ✔️ ✔️ ✔️ ✔️
concept ✔️
const ✔️ ✔️ ✔️ ✔️
const_cast ✔️ ✔️ ✔️ ✔️
constexpr ✔️ ✔️ ✔️
continue ✔️ ✔️ ✔️ ✔️
decltype ✔️ ✔️ ✔️
default ✔️ ✔️ ✔️ ✔️
delete ✔️ ✔️ ✔️ ✔️
do ✔️ ✔️ ✔️ ✔️
double ✔️ ✔️ ✔️ ✔️
dynamic_cast ✔️ ✔️ ✔️ ✔️
else ✔️ ✔️ ✔️ ✔️
enum ✔️ ✔️ ✔️ ✔️
explicit ✔️ ✔️ ✔️ ✔️
export ✔️ ✔️ ✔️ ✔️
extern ✔️ ✔️ ✔️ ✔️
false ✔️ ✔️ ✔️ ✔️
float ✔️ ✔️ ✔️ ✔️
for ✔️ ✔️ ✔️ ✔️
friend ✔️ ✔️ ✔️ ✔️
goto ✔️ ✔️ ✔️ ✔️
if ✔️ ✔️ ✔️ ✔️
inline ✔️ ✔️ ✔️ ✔️
int ✔️ ✔️ ✔️ ✔️
long ✔️ ✔️ ✔️ ✔️
mutable ✔️ ✔️ ✔️ ✔️
namespace ✔️ ✔️ ✔️ ✔️
new ✔️ ✔️ ✔️ ✔️
noexcept ✔️ ✔️ ✔️
not ✔️ ✔️ ✔️ ✔️
not_eq ✔️ ✔️ ✔️ ✔️
nullptr ✔️ ✔️ ✔️
operator ✔️ ✔️ ✔️ ✔️
or ✔️ ✔️ ✔️ ✔️
or_eq ✔️ ✔️ ✔️ ✔️
private ✔️ ✔️ ✔️ ✔️
protected ✔️ ✔️ ✔️ ✔️
public ✔️ ✔️ ✔️ ✔️
register ✔️ ✔️ ✔️ ✔️
reinterpret_cast ✔️ ✔️ ✔️ ✔️
requires ✔️
return ✔️ ✔️ ✔️ ✔️
short ✔️ ✔️ ✔️ ✔️
signed ✔️ ✔️ ✔️ ✔️
sizeof ✔️ ✔️ ✔️ ✔️
static ✔️ ✔️ ✔️ ✔️
static_assert ✔️ ✔️ ✔️
static_cast ✔️ ✔️ ✔️ ✔️
struct ✔️ ✔️ ✔️ ✔️
switch ✔️ ✔️ ✔️ ✔️
template ✔️ ✔️ ✔️ ✔️
this ✔️ ✔️ ✔️ ✔️
thread_local ✔️ ✔️ ✔️
throw ✔️ ✔️ ✔️ ✔️
true ✔️ ✔️ ✔️ ✔️
try ✔️ ✔️ ✔️ ✔️
typedef ✔️ ✔️ ✔️ ✔️
typeid ✔️ ✔️ ✔️ ✔️
typename ✔️ ✔️ ✔️ ✔️
union ✔️ ✔️ ✔️ ✔️
unsigned ✔️ ✔️ ✔️ ✔️
using ✔️ ✔️ ✔️ ✔️
virtual ✔️ ✔️ ✔️ ✔️
void ✔️ ✔️ ✔️ ✔️
volatile ✔️ ✔️ ✔️ ✔️
wchar_t ✔️ ✔️ ✔️ ✔️
while ✔️ ✔️ ✔️ ✔️
xor ✔️ ✔️ ✔️ ✔️
xor_eq ✔️ ✔️ ✔️ ✔️

punctuator

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
{ ✔️ ✔️ ✔️ ✔️
} ✔️ ✔️ ✔️ ✔️
[ ✔️ ✔️ ✔️ ✔️
] ✔️ ✔️ ✔️ ✔️
# ✔️ ✔️ ✔️ ✔️
## ✔️ ✔️ ✔️ ✔️
( ✔️ ✔️ ✔️ ✔️
) ✔️ ✔️ ✔️ ✔️
; ✔️ ✔️ ✔️ ✔️
: ✔️ ✔️ ✔️ ✔️
... ✔️ ✔️ ✔️ ✔️
? ✔️ ✔️ ✔️ ✔️
:: ✔️ ✔️ ✔️ ✔️
. ✔️ ✔️ ✔️ ✔️
.* ✔️ ✔️ ✔️ ✔️
+ ✔️ ✔️ ✔️ ✔️
- ✔️ ✔️ ✔️ ✔️
* ✔️ ✔️ ✔️ ✔️
/ ✔️ ✔️ ✔️ ✔️
% ✔️ ✔️ ✔️ ✔️
^ ✔️ ✔️ ✔️ ✔️
& ✔️ ✔️ ✔️ ✔️
| ✔️ ✔️ ✔️ ✔️
~ ✔️ ✔️ ✔️ ✔️
! ✔️ ✔️ ✔️ ✔️
= ✔️ ✔️ ✔️ ✔️
< ✔️ ✔️ ✔️ ✔️
> ✔️ ✔️ ✔️ ✔️
+= ✔️ ✔️ ✔️ ✔️
-= ✔️ ✔️ ✔️ ✔️
*= ✔️ ✔️ ✔️ ✔️
/= ✔️ ✔️ ✔️ ✔️
%= ✔️ ✔️ ✔️ ✔️
^= ✔️ ✔️ ✔️ ✔️
&= ✔️ ✔️ ✔️ ✔️
|= ✔️ ✔️ ✔️ ✔️
<< ✔️ ✔️ ✔️ ✔️
>> ✔️ ✔️ ✔️ ✔️
<<= ✔️ ✔️ ✔️ ✔️
>>= ✔️ ✔️ ✔️ ✔️
== ✔️ ✔️ ✔️ ✔️
!= ✔️ ✔️ ✔️ ✔️
<= ✔️ ✔️ ✔️ ✔️
>= ✔️ ✔️ ✔️ ✔️
&& ✔️ ✔️ ✔️ ✔️
|| ✔️ ✔️ ✔️ ✔️
++ ✔️ ✔️ ✔️ ✔️
-- ✔️ ✔️ ✔️ ✔️
, ✔️ ✔️ ✔️ ✔️
->* ✔️ ✔️ ✔️ ✔️
-> ✔️ ✔️ ✔️ ✔️
<=> ✔️

identifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
identifier-nondigit ✔️ ✔️ ✔️ ✔️
identifier identifier-nondigit ✔️ ✔️ ✔️ ✔️
identifier digit ✔️ ✔️ ✔️ ✔️

identifier-nondigit

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
nondigit ✔️ ✔️ ✔️ ✔️

nondigit

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
_ ✔️ ✔️ ✔️ ✔️
a ✔️ ✔️ ✔️ ✔️
b ✔️ ✔️ ✔️ ✔️
c ✔️ ✔️ ✔️ ✔️
d ✔️ ✔️ ✔️ ✔️
e ✔️ ✔️ ✔️ ✔️
f ✔️ ✔️ ✔️ ✔️
g ✔️ ✔️ ✔️ ✔️
h ✔️ ✔️ ✔️ ✔️
i ✔️ ✔️ ✔️ ✔️
j ✔️ ✔️ ✔️ ✔️
k ✔️ ✔️ ✔️ ✔️
l ✔️ ✔️ ✔️ ✔️
m ✔️ ✔️ ✔️ ✔️
n ✔️ ✔️ ✔️ ✔️
o ✔️ ✔️ ✔️ ✔️
p ✔️ ✔️ ✔️ ✔️
q ✔️ ✔️ ✔️ ✔️
r ✔️ ✔️ ✔️ ✔️
s ✔️ ✔️ ✔️ ✔️
t ✔️ ✔️ ✔️ ✔️
u ✔️ ✔️ ✔️ ✔️
v ✔️ ✔️ ✔️ ✔️
w ✔️ ✔️ ✔️ ✔️
x ✔️ ✔️ ✔️ ✔️
y ✔️ ✔️ ✔️ ✔️
z ✔️ ✔️ ✔️ ✔️
A ✔️ ✔️ ✔️ ✔️
B ✔️ ✔️ ✔️ ✔️
C ✔️ ✔️ ✔️ ✔️
D ✔️ ✔️ ✔️ ✔️
E ✔️ ✔️ ✔️ ✔️
F ✔️ ✔️ ✔️ ✔️
G ✔️ ✔️ ✔️ ✔️
H ✔️ ✔️ ✔️ ✔️
I ✔️ ✔️ ✔️ ✔️
J ✔️ ✔️ ✔️ ✔️
K ✔️ ✔️ ✔️ ✔️
L ✔️ ✔️ ✔️ ✔️
M ✔️ ✔️ ✔️ ✔️
N ✔️ ✔️ ✔️ ✔️
O ✔️ ✔️ ✔️ ✔️
P ✔️ ✔️ ✔️ ✔️
Q ✔️ ✔️ ✔️ ✔️
R ✔️ ✔️ ✔️ ✔️
S ✔️ ✔️ ✔️ ✔️
T ✔️ ✔️ ✔️ ✔️
U ✔️ ✔️ ✔️ ✔️
V ✔️ ✔️ ✔️ ✔️
W ✔️ ✔️ ✔️ ✔️
X ✔️ ✔️ ✔️ ✔️
Y ✔️ ✔️ ✔️ ✔️
Z ✔️ ✔️ ✔️ ✔️

digit

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
0 ✔️ ✔️ ✔️ ✔️
1 ✔️ ✔️ ✔️ ✔️
2 ✔️ ✔️ ✔️ ✔️
3 ✔️ ✔️ ✔️ ✔️
4 ✔️ ✔️ ✔️ ✔️
5 ✔️ ✔️ ✔️ ✔️
6 ✔️ ✔️ ✔️ ✔️
7 ✔️ ✔️ ✔️ ✔️
8 ✔️ ✔️ ✔️ ✔️
9 ✔️ ✔️ ✔️ ✔️

Expressions

id-expression

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
unqualified-id ✔️ ✔️ ✔️ ✔️
qualified-id ✔️ ✔️ ✔️ ✔️

unqualified-id

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
identifier ✔️ ✔️ ✔️ ✔️

qualified-id

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
nested-name-specifier unqualified-id ✔️ ✔️ ✔️ ✔️

nested-name-specifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
identifier :: ✔️ ✔️ ✔️ ✔️
nested-name-specifier identifier :: ✔️ ✔️ ✔️ ✔️

Statements

Declarations

decl-specifier-seq

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
decl-specifier ✔️ ✔️ ✔️ ✔️

decl-specifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
defining-type-specifier ✔️ ✔️ ✔️ ✔️

defining-type-specifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
type-specifier ✔️ ✔️ ✔️ ✔️

type-specifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
simple-type-specifier ✔️ ✔️ ✔️ ✔️

simple-type-specifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
nested-name-specifier[opt] identifier ✔️ ✔️ ✔️ ✔️
char ✔️ ✔️ ✔️ ✔️
wchar_t ✔️ ✔️ ✔️ ✔️
bool ✔️ ✔️ ✔️ ✔️
short ✔️ ✔️ ✔️ ✔️
int ✔️ ✔️ ✔️ ✔️
long ✔️ ✔️ ✔️ ✔️
signed ✔️ ✔️ ✔️ ✔️
unsigned ✔️ ✔️ ✔️ ✔️
float ✔️ ✔️ ✔️ ✔️
double ✔️ ✔️ ✔️ ✔️

Declarators

declarator

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
ptr-declarator ✔️ ✔️ ✔️ ✔️

ptr-declarator

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
noptr-declarator ✔️ ✔️ ✔️ ✔️

noptr-declarator

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
declarator-id ✔️ ✔️ ✔️ ✔️
noptr-declarator parameters-and-qualifiers ✔️ ✔️ ✔️ ✔️

parameters-and-qualifiers

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
( parameter-declaration-clause ) cv-qualifier-seq[opt] ✔️ ✔️ ✔️ ✔️

cv-qualifier-seq

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
cv-qualifier cv-qualifier-seq[opt] ✔️ ✔️ ✔️ ✔️

cv-qualifier

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
const ✔️ ✔️ ✔️ ✔️
volatile ✔️ ✔️ ✔️ ✔️

declarator-id

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
id-expression ✔️ ✔️ ✔️ ✔️

parameter-declaration-clause

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
parameter-declaration-list[opt] ...[opt] ✔️ ✔️ ✔️ ✔️
parameter-declaration-list , ...[opt] ✔️ ✔️ ✔️ ✔️

parameter-declaration-list

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
parameter-declaration ✔️ ✔️ ✔️ ✔️
parameter-declaration-list , parameter-declaration ✔️ ✔️ ✔️ ✔️

parameter-declaration

Definitions C++ 2003 C++ 2011 C++ 2014 C++ 2017
decl-specifier-seq ✔️ ✔️ ✔️ ✔️

Classes

Derived classes

Special member functions

Overloading

Templates

Exception handling

Index of rules