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.
More seriously, if I was to make a bottom-up parser, I would start with a 'statement' root node, and push the items into it as they get parsed. Once a 'statement was complete, I'd expect a single branch from that 'statement' node to a 'type of statement' node, from which a true tree would form.
parse the ')' to a rparen and build a 'rparen' leaf
parse the 'true' and place it in the tree
parse the '(' to a lparen and insert it
... 'while' ...
So my approach would be to start with a blank statement at the beginning
add the rparen to it, so the tree is: Statement -> RParen
add the 'true' to it, so the tree is now: Statement -> True -> RParen
add the lparen to it, so: Statement -> LParen -> True -> RParen
the LParen can trigger a reduction at this step if you want
add the 'while': Statement -> While -> LParen -> True -> RParen
and reduce everything there if you want.
It would be a pretty straight tree in this case, but so be it. Maybe my understanding about top-down and bottom-up is incorrect.
Yeah, but seriously: Who reads the Insider News???
Anything that is unrelated to elephants is irrelephant Anonymous - The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 - Never argue with a fool. Onlookers may not be able to tell the difference. Mark Twain
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
Last Visit: 28-Mar-20 21:08 Last Update: 28-Mar-20 21:09