Grammar of C++ Declarations

declaration:

decl-specifiersopt declarator-listopt ;
asm-declaration
function-definition
linkage-specification
template-declaration:

asm-declaration:

__asm( string-literal );

decl-specifiers:

decl-specifiersopt decl-specifier

decl-specifier:

storage-class-specifier
type-specifier
fct-specifier
friend
typedef
__declspec ( extended-decl-modifier-seq )

storage-class-specifier:

auto
register
static
extern

fct-specifier:

inline
virtual

type-specifier:

simple-type-name
class-specifier
enum-specifier
elaborated-type-specifier
const
volatile

extended-decl-modifier-seq:

extended-decl-modifieropt
extended-decl-modifier extended-decl-modifier-seq

extended-decl-modifier:

thread
naked
dllimport
dllexport

simple-type-name:

complete-class-name
qualified-type-name
char
short
int
long
signed
unsigned
float
double
void

elaborated-type-specifier:

class-key  identifier
class-key  class-name
enum-name

class-key:

class
struct
union

qualified-type-name:

typedef-name
class-name :: qualified-type-name

complete-class-name:

qualified-class-name
:: qualified-class-name

qualified-class-name:

class-name
class-name :: qualified-class-name

enum-specifier:

enum identifieropt { enum-listopt }

enum-list:

enumerator
enum-list , enumerator

enumerator:

identifier
identifier = constant-expression

constant-expression:

conditional-expression

linkage-specification:

extern string-literal { declaration-listopt }
extern string-literal declaration

declaration-list:

declaration
declaration-list  declaration

template-declaration:

template < template-argument-list > declaration

template-argument-list:

template-argument
template-argument-list , template-argument

template-argument:

type-argument
argument-declaration

type-argument:

class identifier

template-class-name:

template-name < template-arg-list >

template-arg-list:

template-arg
template-arg-list , template-arg

template-arg:

expression
type-name

original-namespace-name :

identifier

namespace-definition :

original-namespace-definition
extension-namespace-definition
unnamed-namespace-definition

original-namespace-definition :

namespace identifier { namespace-body }

extension-namespace-definition :

namespace original-namespace-name { namespace-body }

unnamed-namespace-definition :

namespace { namespace-body }

namespace-body :

declaration-seqopt

id-expression :

unqualified-id
qualified-id

nested-name-specifier :

class-or-namespace-name :: nested-name-specifieropt

class-or-namespace-name :

class-name
namespace-name

namespace-name :

original-namespace-name
namespace-alias

namespace-alias :

identifier

namespace-alias-definition :

namespace identifier = qualified-namespace-specifier;

qualified-namespace-specifier :

::opt nested-name-specifieropt class-or-namespace-name

using-declaration :

using ::opt nested-name-specifier unqualified-id
using :: unqualified-id

using-directive :

using namespace ::opt nested-name-specifieropt namespace-name