Grammar: What's in a type-specifier-seq?

O

Ole Nielsby

The C++ syntax goes like:

type-id:
type-specifier-seq abstract-declarator(opt)
type-specifier-seq:
type-specifier type-specifier-seq(opt)

which means, a type-id has 1 or more type-specifiers in it.
This introduces ambiguities. Assuming no namespace, and declarations

class a{public: class b{};};
class b{};

this type-id:

a::b

could parse as a seq of two type-specifiers, a and ::b .

Is it possible to tighten the grammar into something like:

type-id:
type-modifier-seq(opt) type-specifier abstract-declarator(opt)
type-modifier-seq:
type-modifier type-modifier-seq(opt)

type-modifier
_signed_
_unsigned_
_short_
_long_
...

.... or are matters more complicated than that? Are there situations where
a type-id would be prefixed by anything other than
signed/unsigned/short/long keywords?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top