-
Notifications
You must be signed in to change notification settings - Fork 4
Introduce the bruteforce parser (interpreter?). #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
CAD97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks fine. Obviously src/slow_bruteforce_interpreter.rs is the tricky part.
|
I think I'd like this to bake a while longer, at least to get to test it with @oli-obk also expressed interest in experimenting with the "web frontend" idea. EDIT: some initial testing with |
CAD97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally: Everything outside slow_bruteforce_interpreter.rs looks good to me so far. I think some of the FIXME in that file can be pretty easily addressed, though. (Generally, it looks fine, but I've only really scanned that file so far.)
CAD97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good here
1d4f1f5 to
2a3bfe1
Compare
| }; | ||
| } | ||
|
|
||
| testcases![ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to sync these with gll, additions were made there.
| Rule::RepeatMore(rule, None) => { | ||
| NodeShape::Split(rule, cx.intern(Rule::RepeatMany(rule, None))) | ||
| Rule::RepeatMany(..) | Rule::RepeatMore(..) => { | ||
| NodeShape::Alias(self.expand_repeats(cx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be reverted/replaced with self.expand_repeats(cx).node_shape(cx, named_rules).
src/forest.rs
Outdated
| } | ||
| } | ||
|
|
||
| // TODO(eddyb) remove this entirely, only user of it left is `ListHandle`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be dealt with ASAP.
src/bruteforce.rs
Outdated
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the nastiest part of parsing atm, an emulated stack to avoid blowing up the real one.
(Using a queue instead of a stack looks too much like GLL for my own comfort, otherwise I would've probably done it that way)
I'm wondering how I can make this more readable - maybe keep more things explicitly on the emulated stack? Use an enum with variants as an explicit state machine?
9f32647 to
baec49d
Compare
| #[derive(Debug)] | ||
| enum SmallSet<T> { | ||
| One(T), | ||
| Many(BTreeSet<T>), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be cheaper to use e.g. im::OrdSet for this.
Check out
src/lyg.rsfor an example involving pattern-matching parse nodes, and the two tests (ported over from thegllcrate) for how to use the interpret and what the output is like.I'm open to suggestions on the API and formatting, it's a bit arbitrary at the moment.