Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2874

Re: Why no shift-shift conflicts?

Path csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From "Ev. Drikos" <drikosev@gmail.com>
Newsgroups comp.compilers
Subject Re: Why no shift-shift conflicts?
Date Fri, 28 Jan 2022 15:22:46 +0200
Organization Aioe.org NNTP Server
Lines 41
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <22-01-117@comp.compilers> (permalink)
References <22-01-112@comp.compilers>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
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
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
Content-Language en-US
Xref csiph.com comp.compilers:2874

Show key headers only | View raw


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]

Back to comp.compilers | Previous | NextPrevious in thread | Find similar


Thread

Why no shift-shift conflicts? Roger L Costello <costello@mitre.org> - 2022-01-25 21:58 +0000
  Re: Why no shift-shift conflicts? Kaz Kylheku <480-992-1380@kylheku.com> - 2022-01-28 01:20 +0000
    Re: Why no shift-shift conflicts? Andy Walker <anw@cuboid.co.uk> - 2022-01-28 10:13 +0000
      Re: Parsing multiple inputs, was Why no shift-shift conflicts? Thomas Koenig <tkoenig@netcologne.de> - 2022-01-28 19:19 +0000
      Re: Parsing multiple inputs, was Why no shift-shift conflicts? Andy Walker <anw@cuboid.co.uk> - 2022-01-28 19:42 +0000
  Re: Why no shift-shift conflicts? "Ev. Drikos" <drikosev@gmail.com> - 2022-01-28 15:22 +0200

csiph-web