Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2869
| From | Roger L Costello <costello@mitre.org> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Why no shift-shift conflicts? |
| Date | 2022-01-25 21:58 +0000 |
| Organization | Compilers Central |
| Message-ID | <22-01-112@comp.compilers> (permalink) |
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]
Back to comp.compilers | Previous | Next — Next in thread | Find similar
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