Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: "Ev. Drikos" 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> 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 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]