Click here to Skip to main content
14,387,888 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: I went down to the paint store to get thinner... Pin
Ron Anders20-Aug-19 16:53
MemberRon Anders20-Aug-19 16:53 
GeneralRe: I went down to the paint store to get thinner... Pin
Ravi Bhavnani20-Aug-19 18:11
professionalRavi Bhavnani20-Aug-19 18:11 
GeneralRe: I went down to the paint store to get thinner... Pin
Rajesh R Subramanian20-Aug-19 22:40
professionalRajesh R Subramanian20-Aug-19 22:40 
GeneralRe: I went down to the paint store to get thinner... Pin
Jacquers20-Aug-19 21:26
MemberJacquers20-Aug-19 21:26 
GeneralRe: I went down to the paint store to get thinner... Pin
Rajesh R Subramanian20-Aug-19 22:41
professionalRajesh R Subramanian20-Aug-19 22:41 
GeneralRe: I went down to the paint store to get thinner... Pin
"mega"-in-a-fake-beard20-Aug-19 22:58
professional"mega"-in-a-fake-beard20-Aug-19 22:58 
GeneralRe: I went down to the paint store to get thinner... Pin
CodeWraith21-Aug-19 0:22
MemberCodeWraith21-Aug-19 0:22 
General*headdesk* *headdesk* *headdesk* Pin
honey the codewitch20-Aug-19 11:00
Memberhoney the codewitch20-Aug-19 11:00 
An LR parser works like this

Fetch = tokenFoo
Fetch = tokenBar
Fetch = tokenBaz
// parser recognizes those three in a row so it reduces to a rule
Foobar -> tokenFoo tokenBar tokenBaz

You don't get the rule to reduce to until after the tokens are read. You have no idea how many tokens it takes to resolve a rule until after the fact. Which is fine. Usually.

So to build a tree, you have to keep a stack, push any tokens fetched, and then whenever you reduce to a rule, you pop the tokens on the right hand side of the rule, and push a new token for the left hand side of the rule. Easy.

The trouble is when an error is encountered. You won't necessarily get the right number of tokens back

(the parser can actually handle this part, but the tree builder can't)
Fetch = tokenFoo
Fetch = error
Reduce = FooBar -> tokenFoo error ???

Ouch. I don't have enough tokens.

The trouble is, I don't know I don't have enough tokens until the stack is empty.

So basically, I can't even build trees from a shift reduce/LR parser if there are errors in the input.

This is BAD.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: *headdesk* *headdesk* *headdesk* Pin
Jörgen Andersson20-Aug-19 21:34
professionalJörgen Andersson20-Aug-19 21:34 
GeneralRe: *headdesk* *headdesk* *headdesk* Pin
honey the codewitch21-Aug-19 0:14
Memberhoney the codewitch21-Aug-19 0:14 
GeneralRe: *headdesk* *headdesk* *headdesk* Pin
BillWoodruff21-Aug-19 6:15
mveBillWoodruff21-Aug-19 6:15 
GeneralEstimating software like omelettes Pin
raddevus20-Aug-19 9:20
mvaraddevus20-Aug-19 9:20 
GeneralRe: Estimating software like omelettes Pin
Marc Clifton20-Aug-19 9:36
mvaMarc Clifton20-Aug-19 9:36 
GeneralRe: Estimating software like omelettes Pin
devenv.exe20-Aug-19 9:50
professionaldevenv.exe20-Aug-19 9:50 
GeneralRe: Estimating software like omelettes Pin
raddevus20-Aug-19 9:54
mvaraddevus20-Aug-19 9:54 
GeneralRe: Estimating software like omelettes Pin
BStorrar21-Aug-19 4:21
MemberBStorrar21-Aug-19 4:21 
GeneralRe: Estimating software like omelettes Pin
dandy7220-Aug-19 9:53
Memberdandy7220-Aug-19 9:53 
GeneralRe: Estimating software like omelettes Pin
raddevus20-Aug-19 9:57
mvaraddevus20-Aug-19 9:57 
GeneralRe: Estimating software like omelettes PinPopular
Gary R. Wheeler20-Aug-19 11:28
MemberGary R. Wheeler20-Aug-19 11:28 
GeneralRe: Estimating software like omelettes Pin
raddevus20-Aug-19 11:31
mvaraddevus20-Aug-19 11:31 
GeneralRe: Estimating software like omelettes Pin
Gary R. Wheeler20-Aug-19 11:49
MemberGary R. Wheeler20-Aug-19 11:49 
GeneralRe: Estimating software like omelettes Pin
raddevus20-Aug-19 11:54
mvaraddevus20-Aug-19 11:54 
GeneralRe: Estimating software like omelettes Pin
Gary R. Wheeler20-Aug-19 15:15
MemberGary R. Wheeler20-Aug-19 15:15 
GeneralRe: Estimating software like omelettes Pin
raddevus21-Aug-19 2:37
mvaraddevus21-Aug-19 2:37 
GeneralRe: Estimating software like omelettes Pin
Rajesh R Subramanian20-Aug-19 22:43
professionalRajesh R Subramanian20-Aug-19 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.