On 13.02.2014 01:00, Iain Buclaw wrote:
This might be because the rules I have in place are not complete (I'm
not implementing a complete D expression parser), but I have my doubts
on this, and currently leaning on a possible problem in the documentation.
I've built up rules in yacc based on what's documented here:
http://dlang.org/expression.html
However I seem to be getting shift/reduce conflicts around:
AndAndExpression:
OrExpression
| AndAndExpression && OrExpression
CmpExpression
| AndAndExpression && CmpExpression
;
OrExpression:
XorExpression
| OrExpression | XorExpression
;
XorExpression:
AndExpression
| XorExpression ^ AndExpression
;
AndExpression:
ShiftExpression
| AndExpression & ShiftExpression
;
CmpExpression:
ShiftExpression
| EqualExpression
| IdentityExpression
| RelExpression
;
CmpExpression:
ShiftExpression
| EqualExpression
| IdentityExpression
| RelExpression
;
I think this is by design to disallow comparison operators and binary
operators in the same expression without paranthesis:
int x = a & b < c;
op.d(2): Error: b < c must be parenthesized when next to operator &
The grammar in the spec doesn't play nice with generators and isn't
always correct, but in this case, I think it is.