Walter - Discrepancy between EqualExpression spec and implementation

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun May 28 14:17:27 PDT 2006


I'm writing a small scripting language with a syntax based on D, and as 
such, I'm basing some of the parsing code off the the DMD frontend source. 
I've found a discrepancy between the spec and the code, though, and I'm not 
sure if it's a bug or if it was changed in the code on purpose and the spec 
just hasn't been updated.

For EqualExpressions, the following grammar is given:

EqualExpression:
    RelExpression
    EqualExpression == RelExpression
    EqualExpression != RelExpression
    EqualExpression is RelExpression
    EqualExpression !is RelExpression

Notice that the left-hand operand of the operators is an EqualExpression.

However, in the code (parse.c line 4365), instead of using parseEqualExp() 
to get the left-hand operand as I would have expected, it instead uses 
parseRelExp().  Meaning that the code implements the following grammar 
instead:

EqualExpression:
    RelExpression
    RelExpression == RelExpression
    RelExpression != RelExpression
    RelExpression is RelExpression
    RelExpression !is RelExpression

I'm pretty sure only Walter can answer this one! 





More information about the Digitalmars-d mailing list