February 13, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 13 February 2014 02:23, Walter Bright <newshound2@digitalmars.com> wrote: > On 2/12/2014 5:37 PM, Brian Schott wrote: >> >> On Thursday, 13 February 2014 at 01:28:39 UTC, Iain Buclaw wrote: >>> >>> On 13 February 2014 01:16, Walter Bright <newshound2@digitalmars.com> wrote: >>>> >>>> On 2/12/2014 4:24 PM, Iain Buclaw wrote: >>>>> >>>>> >>>>> In any case, everything looks lean enough that I'll probably believe your documented grammar more than the official dlang site. ;-) >>>> >>>> >>>> >>>> Should issue pull requests for errors found in the grammar! >>> >>> >>> Will do ... in the morning. >> >> >> See_also: http://d.puremagic.com/issues/show_bug.cgi?id=10233 > > > Thank you. It's important to make such a log of all such errors you find, otherwise the next poor soul will have to suffer through it all over again. I checked over the already existing reports, and this is what I'm seeing: http://d.puremagic.com/issues/show_bug.cgi?id=10232 |
February 13, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
On 13 February 2014 06:17, Kenji Hara <k.hara.pg@gmail.com> wrote:
> 2014-02-13 9:24 GMT+09:00 Iain Buclaw <ibuclaw@gdcproject.org>:
>
>> On 13 February 2014 00:18, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
>> > On 13 February 2014 00:06, Brian Schott <briancschott@gmail.com> wrote:
>> >> On Thursday, 13 February 2014 at 00:00:11 UTC, Iain Buclaw wrote:
>> >>>
>> >>> I'm just curious if anyone else has stumbled onto this, and whether or
>> >>> not
>> >>> it's just human error on my part. :o)
>> >>>
>> >>> Regards
>> >>> Iain.
>> >>
>> >>
>> >> It's dangerous to go alone. Take this!
>> >>
>> >> https://github.com/Hackerpilot/DGrammar
>> >
>> > Thanks! Having a look at D.g4, I'm seeing that you do the same with the rules:
>> >
>>
>> In any case, everything looks lean enough that I'll probably believe your documented grammar more than the official dlang site. ;-)
>
>
> In git head, 'Grammar' page is added.
>
> https://github.com/D-Programming-Language/dlang.org/blob/master/grammar.dd
>
Bleh, that contains the same mistakes!
|
February 14, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw |
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.
|
February 14, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On 2/13/2014 12:42 AM, Iain Buclaw wrote:
> On 13 February 2014 06:17, Kenji Hara <k.hara.pg@gmail.com> wrote:
>> In git head, 'Grammar' page is added.
>>
>> https://github.com/D-Programming-Language/dlang.org/blob/master/grammar.dd
>>
>
> Bleh, that contains the same mistakes!
It should, because it should contain exactly the same grammar as is distributed around the rest of the spec.
The two should be corrected in sync, not independently.
|
February 15, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rainer Schuetze | On 14 February 2014 19:40, Rainer Schuetze <r.sagitario@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. |
February 18, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
On 15 February 2014 20:09, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
> On 14 February 2014 19:40, Rainer Schuetze <r.sagitario@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 '&'
>
As soon as I introduced
PrimaryExpression:
( Expression )
;
I just ended up reverting it back, so the expression parser happily accepts (a & b < c); as well as variants with multiple brackets inside.
At the moment it's just good to get a D expression evaluator thats' actually working, then worry about was is invalid D later. :o)
Regards
Iain.
|
February 18, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Schott | On Thursday, 13 February 2014 at 00:06:11 UTC, Brian Schott wrote:
> On Thursday, 13 February 2014 at 00:00:11 UTC, Iain Buclaw wrote:
>> I'm just curious if anyone else has stumbled onto this, and whether or not it's just human error on my part. :o)
>>
>> Regards
>> Iain.
>
> It's dangerous to go alone. Take this!
>
> https://github.com/Hackerpilot/DGrammar
Brian's ANTLR grammar file is one that matches closely current stat of affairs. I use it in two small Java apps. :)
|
February 18, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Schott | Am Thu, 13 Feb 2014 00:06:10 +0000 schrieb "Brian Schott" <briancschott@gmail.com>: > On Thursday, 13 February 2014 at 00:00:11 UTC, Iain Buclaw wrote: > > I'm just curious if anyone else has stumbled onto this, and whether or not it's just human error on my part. :o) > > > > Regards > > Iain. > > It's dangerous to go alone. Take this! > > https://github.com/Hackerpilot/DGrammar Is it a bad sign if I happen to remember the reference ? :p -- Marco |
February 18, 2014 Re: Redundancy/conflicts in expression rules. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marco Leise | On Tue, 18 Feb 2014 13:18:00 -0500, Marco Leise <Marco.Leise@gmx.de> wrote:
> Am Thu, 13 Feb 2014 00:06:10 +0000
> schrieb "Brian Schott" <briancschott@gmail.com>:
>
>> On Thursday, 13 February 2014 at 00:00:11 UTC, Iain Buclaw wrote:
>> > I'm just curious if anyone else has stumbled onto this, and
>> > whether or not it's just human error on my part. :o)
>> >
>> > Regards
>> > Iain.
>>
>> It's dangerous to go alone. Take this!
>>
>> https://github.com/Hackerpilot/DGrammar
>
> Is it a bad sign if I happen to remember the reference ? :p
No, but it is bad if the "da da da DAAAAA" sound plays in your head while reading it :)
-Steve
|
Copyright © 1999-2021 by the D Language Foundation