Jump to page: 1 2
Thread overview
Redundancy/conflicts in expression rules.
Feb 13, 2014
Iain Buclaw
Feb 13, 2014
Brian Schott
Feb 13, 2014
Iain Buclaw
Feb 13, 2014
Iain Buclaw
Feb 13, 2014
Walter Bright
Feb 13, 2014
Iain Buclaw
Feb 13, 2014
Brian Schott
Feb 13, 2014
Walter Bright
Feb 13, 2014
Iain Buclaw
Feb 13, 2014
Brian Schott
Feb 13, 2014
Kenji Hara
Feb 13, 2014
Iain Buclaw
Feb 14, 2014
Walter Bright
Feb 18, 2014
Dejan Lekic
Feb 18, 2014
Marco Leise
Feb 14, 2014
Rainer Schuetze
Feb 15, 2014
Iain Buclaw
Feb 18, 2014
Iain Buclaw
February 13, 2014
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
;


---
Conflict between 'XorExpression: XorExpression '^' AndExpression' and token '&'
Conflict between 'ShiftExpression: ShiftExpression RSH AddExpression' and token '+'
Conflict between 'ShiftExpression: ShiftExpression RSH AddExpression' and token '-'
Conflict between 'ShiftExpression: ShiftExpression LSH AddExpression' and token '+'
Conflict between 'ShiftExpression: ShiftExpression LSH AddExpression' and token '-'
Conflict between 'AddExpression: AddExpression '+' MulExpression' and token '*'
Conflict between 'AddExpression: AddExpression '-' MulExpression' and token '*'
---


It's not too much of a problem, I can tweak it (so it follows same-ish rules as Java) and it will pass just fine:

AndAndExpression:
        OrExpression
|       AndAndExpression && OrExpression
;

OrExpression:
        XorExpression
|       OrExpression | XorExpression
;

XorExpression:
        AndExpression
|       XorExpression ^ AndExpression
;

AndExpression:
        CmpExpression
|       AndExpression & CmpExpression
;

CmpExpression:
        ShiftExpression
|       EqualExpression
|       IdentityExpression
|       RelExpression
;


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.
February 13, 2014
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
February 13, 2014
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:

andAndExpression:
      orExpression
    | andAndExpression '&&' orExpression
    ;

/*...*/

andExpression:
      cmpExpression
    | andExpression '&' cmpExpression
    ;

cmpExpression:
      shiftExpression
    | equalExpression
    | identityExpression
    | relExpression
    | inExpression
    ;
February 13, 2014
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. ;-)
February 13, 2014
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!
February 13, 2014
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.
February 13, 2014
On Thursday, 13 February 2014 at 01:16:47 UTC, Walter Bright 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!

Use of my parser keeps finding places where my grammar is wrong. Here's an example from today:

https://github.com/Hackerpilot/Dscanner/commit/54118e905f55239fb7c03c101db84b22e4368e51#diff-6331f8b31e134d0bacb245c850fe5404

This reminds me that I haven't synchronized the parser's doc comments with that ANTLR file in a while. Hopefully I'll have time for that on the weekend.
February 13, 2014
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
February 13, 2014
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.
February 13, 2014
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

Kenji Hara


« First   ‹ Prev
1 2