Thread overview
bugs/errors in the D BNF
Jan 12, 2007
BCS
Jan 12, 2007
Kirk McDonald
Jan 13, 2007
Kirk McDonald
January 12, 2007
According to the spec Invariants are allowed in modules? Is this correct.

It's a minor nitpick but a number of productions are missing the ":" after the name.

AsmPrimaryExp,
DebugSpecification,
DecimalExponent,
DotIdentifier,
Filespec,
FunctionLiteral
HexExponent
HexStringChar
Operands
Postfix
SingleQuotedCharacter
SpecialTokenSequence
SuperInterfaces
TemplateParameterList
VersionSpecification

A more major problem is that a number of productions are undefined. I looked at this a while ago and many of them are defined, but under a different name.

BaseClasslist
CatchParameter
DebugStatement
ExpressionList
FloatConstant
IdentiferChar
IdentiferStart
IntegerConstant
IntegerExpression
Invariant
LabeledStatement
NamedCharacterEntity
NumericLiteral
Register
Symbol
TemplateIdentifer
Tuple
VersionStatement

BTW it would be vary nice if all of the productions were links to there definitions.


January 12, 2007
BCS wrote:
> According to the spec Invariants are allowed in modules? Is this correct.
> 
> It's a minor nitpick but a number of productions are missing the ":" after the name.
> 
> AsmPrimaryExp,
> DebugSpecification,
> DecimalExponent,
> DotIdentifier,
> Filespec,
> FunctionLiteral
> HexExponent
> HexStringChar
> Operands
> Postfix
> SingleQuotedCharacter
> SpecialTokenSequence
> SuperInterfaces
> TemplateParameterList
> VersionSpecification
> 
> A more major problem is that a number of productions are undefined. I looked at this a while ago and many of them are defined, but under a different name.
> 
> BaseClasslist
> CatchParameter
> DebugStatement
> ExpressionList
> FloatConstant
> IdentiferChar
> IdentiferStart
> IntegerConstant
> IntegerExpression
> Invariant
> LabeledStatement
> NamedCharacterEntity
> NumericLiteral
> Register
> Symbol
> TemplateIdentifer
> Tuple
> VersionStatement
> 
> BTW it would be vary nice if all of the productions were links to there definitions.
> 
> 

I've been working on a D parser written in Python. It has become abundantly clear during this process that the grammar as defined in the spec is to be found wanting in quite a number of ways. I've been compiling a list of errors in the grammar. It is not in front of me at the moment, but I do plan on posting it at some point.

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org
January 13, 2007
Kirk McDonald wrote:
> I've been working on a D parser written in Python. It has become abundantly clear during this process that the grammar as defined in the spec is to be found wanting in quite a number of ways. I've been compiling a list of errors in the grammar. It is not in front of me at the moment, but I do plan on posting it at some point.
> 

Here it is:

TemplateDeclaration and a few other things are defined but never used anywhere. Therefore:

DeclDef is missing:
    TemplateDeclaration
    ClassTemplateDeclaration
    FunctionTemplateDeclaration
    TemplateMixin
    ConditionalDeclaration
    StaticAssert

TemplateValueParameter is wrong. It should be something like:
    BasicType Declarator
    BasicType Declarator TemplateValueParameterSpecialization
    BasicType Declarator TemplateValueParameterDefault
    BasicType Declarator TemplateValueParameterSpecialization TemplateValueParameterDefault

Declarator is missing:
    BasicType2

Declarator2 is missing:
    BasicType2

The current definition of Parameter is just plain broken.

Parameter should be something like:
    BasicType
    BasicType Declarator = AssignExpression
    InOut BasicType
    InOut BasicType Declarator = AssignExpression

D's syntax allows template instances to be used as expressions. Therefore:

PrimaryExpression is missing:
    TemplateInstance

ImportBind should be:
    Identifier
    Identifier = Identifier

ConditionalDeclaration should be:
    Condition DeclarationBlock
    Condition DeclarationBlock else DeclarationBlock
    Condition : DeclDefs

DeclarationBlock should be:
    DeclDef
    { DeclDefs }
    { }

Therefore, version.html's definition of Declarations is no longer needed.

The definition of DeclarationStatement in the spec does not allow for nested classes, structs, and so forth. Therefore it should be:

DeclarationStatement:
    Declaration
    AggregateStatement
    MixinStatement

MixinStatement:
    TemplateMixin

AggregateStatement:
    AggregateDeclaration
    ClassDeclaration
    InterfaceDeclaration
    EnumDeclaration

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://pyd.dsource.org