-
Notifications
You must be signed in to change notification settings - Fork 25
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
Split off parts of the runtime
module into input
, forest
and parser
.
#115
Conversation
This reverts commit ec48a00.
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 definitely helps clean the code organization up!
I'm actually kind of eager to see the not-gll-specific parts pulled into grammer because that makes it easier for me to go and provide potential improvement refactoring 🙃
Let's wait for qmx or Centril to 👍 this though.
@@ -0,0 +1,546 @@ | |||
use crate::high::{type_lambda, ExistsL, PairL}; |
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.
Could generally use some doc comments on all pub
items in the module.
if splits.len() > 1 { | ||
return Err(MoreThanOne); | ||
} | ||
let &split = splits.iter().next().unwrap(); |
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 seems to have the same structure as in one_choice
-- refactor out this bit?
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.
They're in different(ly typed) maps.
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.
But there must be some common generic interface? Would be sad if not...
.get(&node) | ||
.into_iter() | ||
.flatten() | ||
.cloned() |
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 until here is also repeated in all_choices
-- refactor out?
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.
That's... because this is how you iterate an Option<&Set<T>>
?
.cloned() | ||
.collect(); | ||
let mut seen: BTreeSet<_> = queue.iter().cloned().collect(); | ||
let mut p = 0; |
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.
Could do better than just a one letter name p
. :)
.collect(); | ||
let mut seen: BTreeSet<_> = queue.iter().cloned().collect(); | ||
let mut p = 0; | ||
while let Some(source) = queue.pop_front() { |
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.
Would be good to describe the algorithm used here so future readers need to think less.
None | ||
} | ||
match self.parser.input_consume_left(pat) { | ||
Some(parser) => Some(Runtime { |
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.
Some(parser) => Some(Runtime { | |
Some(parser) => Some(Self { |
current: self.current, | ||
saved: self.saved, | ||
}), | ||
None => None, |
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.
Use ?
}) | ||
} | ||
match self.parser.input_consume_right(pat) { | ||
Some(parser) => Some(Runtime { |
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.
Some(parser) => Some(Runtime { | |
Some(parser) => Some(Self { |
state: self.state, | ||
current: self.current, | ||
saved: self.saved, | ||
}), | ||
None => None, |
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.
Also use ?
} | ||
}) | ||
} | ||
fn step<'i>(self, rt: Runtime<'_, 'i, Self, I>); |
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.
fn step<'i>(self, rt: Runtime<'_, 'i, Self, I>); | |
fn step(self, rt: Runtime<'_, '_, Self, I>); |
Only
runtime
remains GLL-specific, the other modules can be moved togrammer
at some point.