Related articles |
---|
Why no shift-shift conflicts? costello@mitre.org (Roger L Costello) (2022-01-25) |
Re: Why no shift-shift conflicts? 480-992-1380@kylheku.com (Kaz Kylheku) (2022-01-28) |
Re: Why no shift-shift conflicts? anw@cuboid.co.uk (Andy Walker) (2022-01-28) |
Re: Why no shift-shift conflicts? drikosev@gmail.com (Ev. Drikos) (2022-01-28) |
From: | "Ev. Drikos" <drikosev@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 28 Jan 2022 15:22:46 +0200 |
Organization: | Aioe.org NNTP Server |
References: | 22-01-112 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="5804"; mail-complaints-to="abuse@iecc.com" |
Keywords: | parse, LALR, comment |
Posted-Date: | 28 Jan 2022 13:06:10 EST |
Content-Language: | en-US |
On 25/01/2022 23:58, Roger L Costello wrote:
> ...
In example, you would care if you wanted to execute some
actions on-shift, assuming you had a supporting tool. In
example, given this grammar fragment, what the parser is
supposed to do, increase or decrease variable 'a' after
reading '1' on input?
X: '1' { a = a + 1; } '2' 'x'
;
Y: '1' { a = a - 1; } '2' 'y'
;
Z: '1' '2' 'z' { a = 0 }
;
Without the mid-rule actions above, any LR based parser is
capable, after reading '1', to shift it onto a stack without
reject any of the above three rules (imagine ie that an LR
parser moves some dot on the above rules after '1', and the
parser state is combination of the alive dotted items). So,
the parser wouldn't see any conflict in such a transition.
Regards,
Ev. Drikos
[The mid-rule action is a cheat, a shorthand for this:
X: '1' x1 '2' 'x' ;
x1: { a = a + 1; } ;
Y: '1' y1 '2' 'y' ;
y1: { a = a - 1; } ;
That's why those actions create conflicts where there were none before.
-John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.