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) |
Re: Parsing multiple inputs, was Why no shift-shift conflicts? tkoenig@netcologne.de (Thomas Koenig) (2022-01-28) |
Re: Parsing multiple inputs, was Why no shift-shift conflicts? anw@cuboid.co.uk (Andy Walker) (2022-01-28) |
From: | Roger L Costello <costello@mitre.org> |
Newsgroups: | comp.compilers |
Date: | Tue, 25 Jan 2022 21:58:21 +0000 |
Organization: | Compilers Central |
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 |
Thread-Topic: | Why no shift-shift conflicts? |
Thread-Index: | AdgSNRwyAsTP0Hp6SJiU2P+Rns+MJw== |
Content-Language: | en-US |
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]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.