Annex A [gram] (informative)Grammar summary
Tokens
Top of page
1 New context-dependent keywords are introduced into a program
by typedef (7.1.3), namespace (7.3.1),class (clause 9),
enumeration (7.2), and template (clause 14) declarations.
- typedef_name
- IDENTIFIER
- namespace_name
- original_namespace_name
- namespace_alias
- original_namespace_name
- IDENTIFIER
- namespace_alias
- IDENTIFIER
- class_name
- IDENTIFIER
- template_id
- enum_name
- IDENTIFIER
- template_name
- IDENTIFIER
[gram.lex] A.2 Lexical
conventions
Top of page
- preprocessing_token
- HEADER_NAME
- CHARACTER_LITERAL
- STRING_LITERAL
- preprocessing_op_or_punc
- each non_white_space character that cannot be one of the
above
- preprocessing_op_or_punc
- LBRACE
- RBRACE
- LBRACK
- RBRACK
- HASH
- HASHHASH
- LPAREN
- RPAREN
- SEMIC
- COLON
- ELIPSIS
- NEW
- DELETE
- QUESTION
- SCOPE
- DOT
- DOT_STAR
- PLUS
- MINUS
- STAR
- SLASH
- PERCENT
- HAT
- AND
- OR
- TILDE
- NOT
- EQ
- LANGLE
- RANGLE
- PLUS_EQ
- MINUS_EQ
- STAR_EQ
- SLASH_EQ
- PERCENT_EQ
- HAT_EQ
- AND_EQ
- OR_EQ
- LTLT
- GTGT
- GTGT_EQ
- LTLT_EQ
- EQEQ
- NE
- LE
- GE
- ANDAND
- OROR
- INCR
- DECR
- COMMA
- ARROW_STAR
- ARROW
- literal
- INTEGER_LITERAL
- CHARACTER_LITERAL
- FLOATING_LITERAL
- STRING_LITERAL
- BOOLEAN_LITERAL
- identifier_opt
- /* Empty */
- IDENTIFIER
- identifier_list_opt
- /* Empty */
- IDENTIFIER
- identifier_list_opt
IDENTIFIER
- scope_opt
- /* Empty */
- SCOPE
- comma_opt
- /* Empty */
- COMMA
- eplisis_opt
- /* Empty */
- ELIPSIS
Top of page
- translation_unit
- declaration_seq
Top of page
- primary_expression
- literal
- THIS
- LPAREN expression RPAREN
- id_expression
- id_expression
- unqualified_id
- qualified_id
- unqualified_id
- IDENTIFIER
- operator_function_id
- conversion_function_id
- TILDE class_name
- template_id
- qualified_id
- scope_opt nested_name_specifier
template_opt unqualified_id
- SCOPE IDENTIFIER
- SCOPE operator_function_id
- SCOPE template_id
- template_opt
- /* Empty */
- TEMPLATE
- nested_name_specifier
- class_or_namespace_name SCOPE
nested_name_specifier_opt
- class_or_namespace_name SCOPE
TEMPLATE nested_name_specifier
- nested_name_specifier_opt
- /* Empty */
- nested_name_specifier
- class_or_namespace_name
- class_name
- namespace_name
- postfix_expression
- primary_expression
- postfix_expression LBRACK expression RBRACK
- postfix_expression LPAREN expression_list_opt RPAREN
- simple_type_specifier LPAREN
expression_list_opt RPAREN
- TYPENAME scope_opt nested_name_specifier IDENTIFIER LPAREN expression_list_opt RPAREN
- TYPENAME scope_opt nested_name_specifier
template_opt template_id LPAREN
expression_list_opt
RPAREN
- postfix_expression
DOT template_opt id_expression
- postfix_expression ARROW
template_opt id_expression
- postfix_expression DOT pseudo_destructor_name
- postfix_expression ARROW
pseudo_destructor_name
- postfix_expression INCR
- postfix_expression DECR
- DYNAMIC_CAST LANGLE type_id RANGLE LPAREN expression RPAREN
- STATIC_CAST LANGLE type_id RANGLE LPAREN expression RPAREN
- REINTERPRET_CAST LANGLE type_id RANGLE LPAREN
expression RPAREN
- CONST_CAST LANGLE type_id RANGLE LPAREN expression RPAREN
- TYPEID LPAREN expression RPAREN
- TYPEID LPAREN type_id RPAREN
- expression_list
- assignment_expression
- expression_list COMMA assignment_expression
- expression_list_opt
- /* Empty */
- expression_list
- pseudo_destructor_name
- scope_opt nested_name_specifier_opt
type_name SCOPE TILDE type_name
- scope_opt nested_name_specifier
TEMPLATE template_id SCOPE TILDE type_name
- scope_opt nested_name_specifier_opt
TILDE type_name
- unary_expression
- postfix_expression
- INCR cast_expression
- DECR cast_expression
- unary_operator cast_expression
- SIZEOF unary_expression
- SIZEOF LPAREN type_id RPAREN
- new_expression
- delete_expression
- unary_operator
- STAR
- AND
- PLUS
- MINUS
- NOT
- TILDE
- new_expression
- scope_opt NEW new_placement_opt new_type_id new_initializer_opt
- scope_opt NEW new_placement_opt LPAREN type_id RPAREN new_initializer_opt
- new_placement
- LPAREN expression_list RPAREN
- new_placement_opt
- /* Empty */
- new_placement
- new_type_id
- type_specifier_seq new_declarator_opt
- new_declarator
- ptr_operator new_declarator_opt
- direct_new_declarator
- new_declarator_opt
- /* Empty */
- new_declarator
- direct_new_declarator
- LBRACK expression RBRACK
- direct_new_declarator LBRACK
constant_expression RBRACK
- new_initializer
- LPAREN expression_list_opt RPAREN
- new_initializer_opt
- /* Empty */
- new_initializer
- delete_expression
- scope_opt DELETE cast_expression
- scope_opt DELETE_ARRAY cast_expression
- cast_expression
- unary_expression
- LPAREN type_id RPAREN cast_expression
- pm_expression
- cast_expression
- pm_expression DOT_STAR cast_expression
- pm_expression ARROW_STAR cast_expression
- multiplicative_expression
- pm_expression
- multiplicative_expression
STAR pm_expression
- multiplicative_expression
SLASH pm_expression
- multiplicative_expression
PERCENT pm_expression
- additive_expression
- multiplicative_expression
- additive_expression PLUS multiplicative_expression
- additive_expression MINUS multiplicative_expression
- shift_expression
- additive_expression
- shift_expression LTLT additive_expression
- shift_expression GTGT additive_expression
- relational_expression
- shift_expression
- relational_expression
LANGLE shift_expression
- relational_expression
RANGLE shift_expression
- relational_expression
LE shift_expression
- relational_expression
GE shift_expression
- equality_expression
- relational_expression
- equality_expression EQEQ relational_expression
- equality_expression NE relational_expression
- and_expression
- equality_expression
- and_expression AND equality_expression
- exclusive_or_expression
- and_expression
- exclusive_or_expression HAT and_expression
- inclusive_or_expression
- exclusive_or_expression
- inclusive_or_expression OR exclusive_or_expression
- logical_and_expression
- inclusive_or_expression
- logical_and_expression
ANDAND inclusive_or_expression
- logical_or_expression
- logical_and_expression
- logical_or_expression
OROR logical_and_expression
- conditional_expression
- logical_or_expression
- logical_or_expression QUESTION
expression COLON assignment_expression
- assignment_expression
- conditional_expression
- logical_or_expression
assignment_operator assignment_expression
- throw_expression
- assignment_expression_opt
- /* Empty */
- assignment_expression
- assignment_operator
- EQ
- STAR_EQ
- SLASH_EQ
- PERCENT_EQ
- PLUS_EQ
- MINUS_EQ
- GTGT_EQ
- LTLT_EQ
- AND_EQ
- HAT_EQ
- OR_EQ
- expression
- assignment_expression
- expression COMMA assignment_expression
- expression_opt
- /* Empty */
- expression
- constant_expression
- conditional_expression
- constant_expression_opt
- /* Empty */
- constant_expression
Top of page
- statement
- labeled_statement
- expression_statement
- compound_statement
- selection_statement
- iteration_statement
- jump_statement
- declaration_statement
- try_block
- labeled_statement
- IDENTIFIER COLON statement
- CASE constant_expression
COLON statement
- DEFAULT COLON statement
- expression_statement
- expression_opt SEMIC
- compound_statement
- LBRACE statement_seq_opt
RBRACE
- statement_seq
- statement
- statement_seq statement
- statement_seq_opt
- /* Empty */
- statement
- selection_statement
- IF LPAREN condition RPAREN statement
- IF LPAREN condition RPAREN statement ELSE statement
- SWITCH LPAREN condition RPAREN statement
- condition
- expression
- type_specifier_seq declarator EQ assignment_expression
- condition_opt
- /* Empty */
- condition
- iteration_statement
- WHILE LPAREN condition RPAREN statement
- DO statement WHILE LPAREN expression RPAREN SEMIC
- FOR LPAREN for_init_statement
condition_opt SEMIC expression_opt RPAREN statement
- for_init_statement
- expression_statement
- simple_declaration
- jump_statement
- BREAK SEMIC
- CONTINUE SEMIC
- RETURN expression_opt SEMIC
- GOTO IDENTIFIER SEMIC
- declaration_statement
- block_declaration
Top of page
- declaration_seq
- declaration
- declaration_seq declaration
- declaration_seq_opt
- /* Empty */
- declaration
- declaration
- block_declaration
- function_definition
- template_declaration
- explicit_instantiation
- explicit_specialization
- linkage_specification
- namespace_definition
- block_declaration
- simple_declaration
- asm_definition
- namespace_alias_definition
- using_declaration
- using_directive
- simple_declaration
- decl_specifier_seq_opt
init_declarator_list_opt
- decl_specifier
- storage_class_specifier
- type_specifier
- function_specifier
- FRIEND
- TYPEDEF
- decl_specifier_seq
- decl_specifier_seq_opt
decl_specifier
- decl_specifier_seq_opt
- /* Empty */
- decl_specifier_seq_opt
- storage_class_specifier
- AUTO
- REGISTER
- STATIC
- EXTERN
- MUTABLE
- function_specifier
- INLINE
- VIRTUAL
- EXPLICIT
- typedef_name
- IDENTIFIER
- type_specifier
- simple_type_specifier
- class_specifier
- enum_specifier
- elaborated_type_specifier
- cv_qualifier
- simple_type_specifier
- scope_opt nested_name_specifier_opt
type_name
- scope_opt nested_name_specifier
TEMPLATE template_id
- CHAR
- WCHAR
- BOOL
- SHORT
- INT
- LONG
- SIGNED
- UNSIGNED
- FLOAT
- DOUBLE
- VOID
- type_name
- class_name
- enum_name
- typedef_name
- elaborated_type_specifier
- class_key scope_opt nested_name_specifier_opt
IDENTIFIER
- ENUM scope_opt nested_name_specifier_opt
IDENTIFIER
- TYPENAME scope_opt nested_name_specifier IDENTIFIER
- TYPENAME scope_opt nested_name_specifier
template_opt template_id
- enum_name
- IDENTIFIER
- enum_specifier
- ENUM identifier_opt LBRACE
enumerator_list_opt RBRACE
- enumerator_list
- enumerator_definition
- enumerator_list COMMA enumerator_definition
- enumerator_list_opt
- /* Empty */
- enumerator_list
- enumerator_definition
- enumerator
- enumerator EQ constant_expression
- enumerator
- IDENTIFIER
- namespace_name
- original_namespace_name
- namespace_alias
- original_namespace_name
- IDENTIFIER
- namespace_definition
- named_namespace_definition
- unnamed_namespace_definition
- named_namespace_definition
- original_namespace_definition
- extension_namespace_definition
- original_namespace_definition
- NAMESPACE IDENTIFIER LBRACE namespace_body RBRACE
- extension_namespace_definition
- NAMESPACE original_namespace_name LBRACE namespace_body RBRACE
- unnamed_namespace_definition
- NAMESPACE LBRACE namespace_body
RBRACE
- namespace_body
- declaration_seq_opt
- namespace_alias
- IDENTIFIER
- namespace_alias_definition
- NAMESPACE IDENTIFIER EQ qualified_namespace_specifier
SEMIC
- qualified_namespace_specifier
- scope_opt nested_name_specifier_opt
namespace_name
- using_declaration
- USING typename_opt scope_opt nested_name_specifier unqualified_id SEMIC
- USING SCOPE unqualified_id SEMIC
- using_directive
- USING NAMESPACE scope_opt nested_name_specifier_opt
namespace_name SEMIC
- asm_definition
- ASM LPAREN STRING_LITERAL RPAREN SEMIC
- linkage_specification
- EXTERN STRING_LITERAL LBRACE declaration_seq_opt RBRACE
- EXTERN STRING_LITERAL declaration
Top of page
- init_declarator_list
- init_declarator
- init_declarator_list COMMA
init_declarator
- init_declarator_list_opt
- /* Empty */
- init_declarator_list
- init_declarator
- declarator initializer_opt
- declarator
- direct_declarator
- ptr_operator declarator
- direct_declarator
- declarator_id
- direct_declarator LPAREN parameter_declaration_clause
RPAREN cv_qualifier_seq_opt exception_specification_opt
- direct_declarator LBRACK constant_expression_opt RBRACK
- LPAREN declarator RPAREN
- ptr_operator
- STAR cv_qualifier_seq_opt
- AND
- scope_opt nested_name_specifier STAR cv_qualifier_seq_opt
- cv_qualifier_seq
- cv_qualifier cv_qualifier_seq_opt
- cv_qualifier
- CONST
- VOLATILE
- cv_qualifier_opt
- /* Empty */
- cv_qualifier
- declarator_id
- id_expression
- scope_opt nested_name_specifier_opt
type_name
- type_id
- type_specifier_seq abstract_declarator_opt
- type_specifier_seq
- type_specifier type_specifier_seq_opt
- type_specifier_seq_opt
- /* Empty */
- type_specifier_seq
- abstract_declarator
- ptr_operator abstract_declarator_opt
- direct_abstract_declarator
- abstract_declarator_opt
- /* Empty */
- abstract_declarator
- direct_abstract_declarator
- direct_abstract_declarator_optLPAREN
parameter_declaration_clause
RPAREN cv_qualifier_seq_opt exception_specification_opt
- direct_abstract_declarator_opt
LBRACK constant_expression_opt
RBRACK
- LPAREN abstract_declarator
RPAREN
- direct_abstract_declarator_opt
- /* Empty */
- direct_abstract_declarator
- parameter_declaration_clause
- parameter_declaration_list_opt
eplisis_opt
- parameter_declaration_list
COMMA ELIPSIS
- parameter_declaration_list
- parameter_declaration
- parameter_declaration_list
COMMA parameter_declaration
- parameter_declaration_list_opt
- /* Empty */
- parameter_declaration_list
- parameter_declaration
- decl_specifier_seq declarator
- decl_specifier_seq declarator EQ assignment_expression
- decl_specifier_seq abstract_declarator_opt
- decl_specifier_seq abstract_declarator_opt EQ assignment_expression
- function_definition
- decl_specifier_seq_opt
declarator ctor_initializer_optfunction_body
- decl_specifier_seq_opt
declarator function_try_block
- function_body
- compound_statement
- initializer
- EQ initializer_clause
- LPAREN expression_list RPAREN
- initializer_opt
- /* Empty */
- initializer
- initializer_clause
- assignment_expression
- LBRACE initializer_list
COMMA_opt RBRACE
- LBRACE RBRACE
- initializer_list
- initializer_clause
- initializer_list COMMA initializer_clause
Top of page
- class_name
- IDENTIFIER
- template_id
- class_specifier
- class_head LBRACE member_specification_opt
RBRACE
- class_head
- class_key identifier_opt base_clause_opt
- class_key nested_name_specifier IDENTIFIER base_clause_opt
- class_key nested_name_specifier_opt
template_id base_clause_opt
- class_key
- CLASS
- STRUCT
- UNION
- class_key_opt
- /* Empty */
- class_key
- member_specification
- member_declaration member_specification_opt
- access_specifier COLON member_specification_opt
- member_specification_opt
- /* Empty */
- member_specification
- member_declaration
- decl_specifier_seq_opt
member_declarator_list_opt
SEMIC
- function_definition
semic_opt
- scope_opt nested_name_specifier
template_opt unqualified_id SEMIC
- using_declaration
- template_declaration
- member_declarator_list
- member_declarator
- member_declarator_list
COMMA member_declarator
- member_declarator
- declarator pure_specifier_opt
- declarator constant_initializer_opt
- identifier_opt COLON constant_expression
- member_declarator_opt
- /* Empty */
- member_declarator
- pure_specifier
- EQ 0
- pure_specifier_opt
- /* Empty */
- pure_specifier
- constant_initializer
- EQ constant_expression
- constant_initializer_opt
- /* Empty */
- constant_initializer
Top of page
- base_clause
- COLON base_specifier_list
- base_clause_opt
- /* Empty */
- base_clause
- base_specifier_list
- base_specifier
- base_specifier_list COMMA base_specifier
- base_specifier
- scope_opt nested_name_specifier_opt
class_name
- VIRTUAL access_specifier_opt
scope_opt nested_name_specifier_opt
class_name
- access_specifier
virtual_opt scope_opt nested_name_specifier_opt
class_name
- virtual_opt
- /* Empty */
- VIRTUAL
- access_specifier
- PRIVATE
- PROTECTED
- PUBLIC
- access_specifier
- /* Empty */
- access_specifier
[gram.special] A.10
Special member functions
Top of page
- conversion_function_id
- OPERATOR conversion_type_id
- conversion_type_id
- type_specifier_seq conversion_declarator_opt
- conversion_declarator
- ptr_operator conversion_declarator_opt
- conversion_declarator_opt
- /* Empty */
- conversion_declarator
- ctor_initializer
- COLON mem_initializer_list
- ctor_initializer_opt
- /* Empty */
- ctor_initializer
- mem_initializer_list
- mem_initializer
- mem_initializer COMMA mem_initializer_list
- mem_initializer
- mem_initializer_id LPAREN expression_list_opt RPAREN
- mem_initializer_id
- scope_opt nested_name_specifier_opt
class_name
- IDENTIFIER
Top of page
- operator_function_id
- OPERATOR operator_name
- operator_name
- NEW
- DELETE
- NEW_ARRAY
- DELETE_ARRAY
- PLUS
- MINUS
- STAR
- SLASH
- PERCENT
- HAT
- AND
- OR
- TILDE
- NOT
- EQ
- LANGLE
- RANGLE
- PLUS_EQ
- MINUS_EQ
- STAR_EQ
- SLASH_EQ
- PERCENT_EQ
- HAT_EQ
- AND_EQ
- OR_EQ
- LTLT
- GTGT
- GTGT_EQ
- LTLT_EQ
- EQEQ
- NE
- LE
- GE
- ANDAND
- OROR
- INCR
- DECR
- COMMA
- ARROW_STAR
- ARROW
- FUNCTION
- SUBSCRIPT
Top of page
- template_declaration
- export_opt TEMPLATE LANGLE template_parameter_list RANGLE
declaration
- export_opt
- /* Empty */
- EXPORT
- template_parameter_list
- template_parameter
- template_parameter_list COMMA template_parameter
- template_parameter
- type_parameter
- parameter_declaration
- type_parameter
- CLASS identifier_opt
- CLASS identifier_opt EQ
type_id
- TYPENAME identifier_opt
- TYPENAME identifier_opt
EG type_id
- TEMPLATE LANGLE template_parameter_list
RANGLE CLASS identifier_opt
- TEMPLATE LANGLE template_parameter_list
RANGLE CLASS identifier_opt EQ
id_expression
- template_id
- template_name LANGLE template_argument_list_opt
RANGLE
- template_id_opt
- /* Empty */
- template_id
-
- template_name
- IDENTIFIER
- template_argument_list
- template_argument
- template_argument_list
COMMA template_argument
- template_argument_list_opt
- /* Empty */
- template_argument_list
- template_argument
- assignment_expression
- type_id
- id_expression
- explicit_instantiation
- TEMPLATE declaration
- explicit_specialization
- TEMPLATE LANGLE RANGLE declaration
Top of page
- try_block
- TRY compound_statement handler_seq
- function_try_block
- TRY ctor_initializer_opt function_body handler_seq
- handler_seq
- handler handler_seq_opt
- handler_seq_opt
- /* Empty */
- handler_seq
- handler
- CATCH LPAREN exception_declaration RPAREN compound_statement
- exception_declaration
- type_specifier_seq declarator
- type_specifier_seq abstract_declarator
- type_specifier_seq
ELIPSIS
- throw_expression
- THROW assignment_expression_opt
- exception_specification
- THROW LPAREN type_id_list_opt RPAREN
- exception_specification_opt
- /* Empty */
- exception_specification
- type_id_list
- type_id
- type_id_list COMMA type_id
- type_id_list_opt
- /* Empty */
- type_id_list
[gram.cpp] A.14
Preprocessing directives
Top of page
- preprocessing_file
- group_opt
- group
- group_part
- group group_part
- group_opt
- /* Empty */
- group
- group_part
- pp_tokens_opt PP_NEWLINE
- if_section
- control_line
- if_section
- if_group elif_groups_opt else_group_opt endif_line
- if_group
- PP_IF constant_expression
PP_NEWLINE group_opt
- PP_IFDEFIDENTIFIER PP_NEWLINE group_opt
- PP_IFNDEF IDENTIFIER PP_NEWLINE group_opt
- elif_groups
- elif_group
- elif_groups elif_group
- elif_groups_opt
- /* Empty */
- elif_groups
- elif_group
- PP_ELIF constant_expression
PP_NEWLINE group_opt
- else_group
- PP_ELSE PP_NEWLINE group_opt
- else_group_opt
- /* Empty */
- else_group
- endif_line
- PP_ENDIF PP_NEWLINE
- control_line
- PP_INCLUDE pp_tokens PP_NEWLINE
- PP_DEFINE IDENTIFIER replacement_list PP_NEWLINE
- PP_DEFINE IDENTIFIER LPAREN identifier_list_opt RPAREN replacement_list PP_NEWLINE
- PP_UNDEF IDENTIFIER PP_NEWLINE
- PP_LINE pp_tokens PP_NEWLINE
- PP_ERROR pp_tokens_opt PP_NEWLINE
- PP_PRAGMA pp_tokens_opt PP_NEWLINE
- HASH PP_NEWLINE
- replacement_list
- pp_tokens_opt
- pp_tokens
- preprocessing_token
- pp_tokens preprocessing_token
- pp_tokens_opt
- /* Empty */
- pp_tokens