Redundancy/conflicts in expression rules.
Iain Buclaw
ibuclaw at gdcproject.org
Sat Feb 15 12:09:11 PST 2014
On 14 February 2014 19:40, Rainer Schuetze <r.sagitario at gmx.de> wrote:
>
>
> I think this is by design to disallow comparison operators and binary
> operators in the same expression without paranthesis:
>
> int x = a & b < c;
>
Yeah, I didn't buy that argument at first. Not least because it didn't
look like the conflicts came from '&'
> 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.
Enforced brackets could be what is missing here...
---
AndAndExpression:
( OrExpression )
| AndAndExpression && ( OrExpression )
| CmpExpression
| AndAndExpression && CmpExpression
;
/* ... */
AndExpression:
CmpExpression
| AndExpression & ( CmpExpression )
;
---
Bison likes it... however that seems to have broken expression parsing
in other ways. I assume this is because I haven't yet introduced
brackets into the grammar yet. :o)
Regards
Iain.
More information about the Digitalmars-d
mailing list