Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4


devel / comp.compilers / Why no shift-shift conflicts?

SubjectAuthor
* Why no shift-shift conflicts?Roger L Costello
+* Re: Why no shift-shift conflicts?Kaz Kylheku
|`* Re: Why no shift-shift conflicts?Andy Walker
| +- Re: Parsing multiple inputs, was Why no shift-shift conflicts?Thomas Koenig
| `- Re: Parsing multiple inputs, was Why no shift-shift conflicts?Andy Walker
`- Re: Why no shift-shift conflicts?Ev. Drikos

1
Why no shift-shift conflicts?

<22-01-112@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=252&group=comp.compilers#252

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: coste...@mitre.org (Roger L Costello)
Newsgroups: comp.compilers
Subject: Why no shift-shift conflicts?
Date: Tue, 25 Jan 2022 21:58:21 +0000
Organization: Compilers Central
Lines: 27
Sender: news@iecc.com
Approved: comp.compilers@iecc.com
Message-ID: <22-01-112@comp.compilers>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="65898"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, yacc, LALR, comment
Posted-Date: 26 Jan 2022 13:30:57 EST
X-submission-address: compilers@iecc.com
X-moderator-address: compilers-request@iecc.com
X-FAQ-and-archives: http://compilers.iecc.com
Thread-Topic: Why no shift-shift conflicts?
Thread-Index: AdgSNRwyAsTP0Hp6SJiU2P+Rns+MJw==
Content-Language: en-US
 by: Roger L Costello - Tue, 25 Jan 2022 21:58 UTC

Hello Compiler Experts!

I have read that there are shift-reduce conflicts and reduce-reduce
conflicts.

It is my understanding that a "conflict" means the parser doesn't know which
path to take.

Consider this example rule from the Bison manual:

compound: '{' declarations statements '}'
| '{' statements '}'
;

I look at that and think, "There is ambiguity. There are two possible paths to
take. The parser doesn't know which path to take." That is, it looks to me
like a shift-shift conflict.

Why are there no shift-shift conflicts?

/Roger
[Sheesh, it's because that's how LR parsing works. The parser has a state machine and a stack.
When it shifts, it puts the token on the stack and moves to the next state, and it's OK if that
state might be part of more than one rule. It's only when it gets to the end of a rule and needs
to reduce, i.e., pop the tokens for that rule off the stack, give them to the semantic routine,
and push its result token on the stack, that the action has to correspond to a single rule. For more
info I shamelessly recommend chapter 7 of flex&bison. -John]

Re: Why no shift-shift conflicts?

<22-01-115@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=255&group=comp.compilers#255

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.compilers
Subject: Re: Why no shift-shift conflicts?
Date: Fri, 28 Jan 2022 01:20:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Sender: news@iecc.com
Approved: comp.compilers@iecc.com
Message-ID: <22-01-115@comp.compilers>
References: <22-01-112@comp.compilers>
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="3672"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, LALR
Posted-Date: 27 Jan 2022 21:21:00 EST
X-submission-address: compilers@iecc.com
X-moderator-address: compilers-request@iecc.com
X-FAQ-and-archives: http://compilers.iecc.com
 by: Kaz Kylheku - Fri, 28 Jan 2022 01:20 UTC

On 2022-01-25, Roger L Costello <costello@mitre.org> wrote:
> Hello Compiler Experts!
>
> I have read that there are shift-reduce conflicts and reduce-reduce
> conflicts.
>
> It is my understanding that a "conflict" means the parser doesn't know which
> path to take.
>
> Consider this example rule from the Bison manual:
>
> compound: '{' declarations statements '}'
> | '{' statements '}'
> ;
>
> I look at that and think, "There is ambiguity. There are two possible paths to
> take. The parser doesn't know which path to take." That is, it looks to me
> like a shift-shift conflict.

"shift" is the name of an action applied to the *input*. The input can
be regarded as a stack: to shift is to pop the next symbol from the
input stack and deal with it in the algorithm by moving it into the
algorithm's stack, and changing state.

Since there is only one input stream, there cannot be a shift-shift
conflict. There is never any choice regarding which symbol is available
from the input.

Re: Why no shift-shift conflicts?

<22-01-116@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=256&group=comp.compilers#256

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: anw...@cuboid.co.uk (Andy Walker)
Newsgroups: comp.compilers
Subject: Re: Why no shift-shift conflicts?
Date: Fri, 28 Jan 2022 10:13:17 +0000
Organization: Not very much
Lines: 21
Sender: news@iecc.com
Approved: comp.compilers@iecc.com
Message-ID: <22-01-116@comp.compilers>
References: <22-01-112@comp.compilers> <22-01-115@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="4059"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, question, comment
Posted-Date: 28 Jan 2022 13:03:09 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-GB
 by: Andy Walker - Fri, 28 Jan 2022 10:13 UTC

On 28/01/2022 01:20, Kaz Kylheku wrote:
[...]
> Since there is only one input stream, there cannot be a shift-shift
> conflict.

I suppose there is no conceivable use for a parsing process
that operates on several collateral input streams? Such an animal
would not be a conventional compiler implementing a conventional
programming language, but people often invent "little languages"
for specialist purposes, and these often need "little compilers"
to process them. It might help such people if tools similar to
Flex and Bison were available to process multiple streams instead
of having to roll your own [or somehow stitching the inputs into
one stream].

--
Andy Walker, Nottingham.
Andy's music pages: www.cuboid.me.uk/andy/Music
Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Simpson
[It seems pretty exotic. The obvious first question is whether you can
combine the multiple input streams in a prepass and parse them as one. -John]

Re: Why no shift-shift conflicts?

<22-01-117@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=257&group=comp.compilers#257

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: driko...@gmail.com (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
 by: Ev. Drikos - Fri, 28 Jan 2022 13:22 UTC

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]

Re: Parsing multiple inputs, was Why no shift-shift conflicts?

<22-01-118@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=258&group=comp.compilers#258

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.compilers
Subject: Re: Parsing multiple inputs, was Why no shift-shift conflicts?
Date: Fri, 28 Jan 2022 19:19:49 -0000 (UTC)
Organization: news.netcologne.de
Lines: 15
Sender: news@iecc.com
Approved: comp.compilers@iecc.com
Message-ID: <22-01-118@comp.compilers>
References: <22-01-112@comp.compilers> <22-01-115@comp.compilers> <22-01-116@comp.compilers>
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="73900"; mail-complaints-to="abuse@iecc.com"
Keywords: parse
Posted-Date: 28 Jan 2022 15:22:06 EST
X-submission-address: compilers@iecc.com
X-moderator-address: compilers-request@iecc.com
X-FAQ-and-archives: http://compilers.iecc.com
 by: Thomas Koenig - Fri, 28 Jan 2022 19:19 UTC

Andy Walker <anw@cuboid.co.uk> schrieb:
> On 28/01/2022 01:20, Kaz Kylheku wrote:
> [...]
>> Since there is only one input stream, there cannot be a shift-shift
>> conflict.
>
> I suppose there is no conceivable use for a parsing process
> that operates on several collateral input streams?

The information about which stream the input comes from has to
be around. Why not simply put an identifier for the input
stream before the data, and build a conventional parser?

Even a state machine with several inputs can be viewed as
processing several input streams.

Re: Parsing multiple inputs, was Why no shift-shift conflicts?

<22-01-119@comp.compilers>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=259&group=comp.compilers#259

  copy link   Newsgroups: comp.compilers
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From: anw...@cuboid.co.uk (Andy Walker)
Newsgroups: comp.compilers
Subject: Re: Parsing multiple inputs, was Why no shift-shift conflicts?
Date: Fri, 28 Jan 2022 19:42:54 +0000
Organization: Not very much
Lines: 20
Sender: news@iecc.com
Approved: comp.compilers@iecc.com
Message-ID: <22-01-119@comp.compilers>
References: <22-01-112@comp.compilers> <22-01-115@comp.compilers> <22-01-116@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="74459"; mail-complaints-to="abuse@iecc.com"
Keywords: parse
Posted-Date: 28 Jan 2022 15:22:44 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-GB
 by: Andy Walker - Fri, 28 Jan 2022 19:42 UTC

On 28/01/2022 10:13, I wrote:
>     I suppose there is no conceivable use for a parsing process
> that operates on several collateral input streams? [...]
> [It seems pretty exotic.  The obvious first question is whether you can
> combine the multiple input streams in a prepass and parse them as one. -John]

You can; /unless/ there are unresolved shift/shift conflicts!
I suppose a more useful obvious question would be whether there are any
real-life applications for collateral multiple input streams. There are
certainly uses for multiple inputs; but these are usually resolved by
some mechanism such as interrupts or polling, rather than by parsing,
and the streams are handled separately rather than stitched together.
It's possible that there is a chicken-egg situation; no-one thinks of
"compiling" multiple streams because there are no tools to do it, as
there are no applications that anyone has thought of for it.

--
Andy Walker, Nottingham.
Andy's music pages: www.cuboid.me.uk/andy/Music
Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Simpson

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor