problem with declaration grammar?
jerry quinn
jlquinn at optonline.net
Thu Feb 19 20:56:38 PST 2009
Ellery Newcomer Wrote:
> > Maybe I'm missing something. The grammar shown in http://www.digitalmars.com/d/2.0/declaration.html has the following rules:
> >
> > BasicType2:
> > *
> > [ ]
> > [ Expression ]
> > [ Expression .. Expression ]
> > [ Type ]
> > delegate Parameters FunctionAttributesopt
> > function Parameters FunctionAttributesopt
> >
> > Declarator:
> > BasicType2 Declarator DeclaratorSuffixesopt
> > BasicType2 Identifier DeclaratorSuffixesopt
> >
> > With this definition, I don't see how you can get Declarator->Identifier.
> >
> > Jerry
> >
>
> You are correct. BasicType2 can match nothing. It should also be able to
> match what it does above multiple times.
As I'm looking at this further, there seems to be more issues. In particular, I don't think the grammar can parse:
int (*x)(char);
as specified. Doing so gives (my best attempt)
Decl -> BasicType Declarators ;
BasicType -> int
Declarators -> DeclaratorInitializer
DeclaratorInitializer -> Declarator
Declarator -> BasicType2 Identifier DeclaratorSuffixes
BasicType2 -> NULL (assuming that the grammar should be revised like this)
Identifier -> BAD PARSE
More information about the Digitalmars-d
mailing list