Welcome to the Lounge
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.
|I've got a coding problem that I don't know if there's a solution to and it's pretty important.
This isn't a coding question. It's more of a rant.
When a bottom up parser parses input it kind of does things backward.
You get your inputs into the queue:
1. term a
2. term b
3. non-term C
Then a reduce action with a rule
4. Reduce D-> a b C
which tells me to pop C, b, a, and then push D, effectively "replacing" the first 3 entries with 1 entry from step 4
This is all well and good, except when there's errors in the input
let's say there was an error parsing step 1 above - and the error recovery "ate" 2 and 3 leaving me with
1. error #ERROR
Well even if i figured out to reduce to D (which i probably wouldn't) I have the wrong number of items on the stack.
So my tree building fails.
I've tried inserting artificial tokens. I've tried rule rewriting, nothing works. I don't have enough information at any given point to reconstruct what's left of the tree.
So I can do a pull parse on it, but the tree can't be generated from the input.
i get my info back with a class that works like XmlReader with the pull parser
but there's no way to generate a hierarchy for it because the tree is built from the leaves to the root, and a corrupt subtree will corrupt its parents due to the stack issue - and that's IF you don't wind up ending early by trying to pop from an empty stack!
This is my life right now. I never did solve this problem last time I encountered it either.
EDIT: Woo I got it working somewhat
Real programmers use butterflies
modified 20-Feb-20 10:35am.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.