Add parsing for conditionals (cont.)
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
974086a877
commit
8afc2d1bde
29 changed files with 994 additions and 746 deletions
29
src/input.rs
29
src/input.rs
|
|
@ -22,11 +22,20 @@ impl NomoInput {
|
|||
pub fn into_parts(self) -> (Arc<str>, Range<usize>) {
|
||||
(self.backing, self.range)
|
||||
}
|
||||
|
||||
pub fn get_range(&self) -> Range<usize> {
|
||||
self.range.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NomoInputCheckpoint {
|
||||
range: Range<usize>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for NomoInput {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "\"{}\"", self.as_str())
|
||||
write!(f, "{:?} ({:?})", self.as_str(), self.range)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +83,18 @@ impl NomoInput {
|
|||
}
|
||||
}
|
||||
|
||||
impl Offset for NomoInputCheckpoint {
|
||||
fn offset_from(&self, start: &Self) -> usize {
|
||||
self.range.start - start.range.start
|
||||
}
|
||||
}
|
||||
|
||||
impl Offset<NomoInputCheckpoint> for NomoInput {
|
||||
fn offset_from(&self, start: &NomoInputCheckpoint) -> usize {
|
||||
self.range.start - start.range.start
|
||||
}
|
||||
}
|
||||
|
||||
impl Offset for NomoInput {
|
||||
fn offset_from(&self, start: &Self) -> usize {
|
||||
self.as_str().offset_from(&start.as_str())
|
||||
|
|
@ -116,7 +137,7 @@ impl Stream for NomoInput {
|
|||
|
||||
type IterOffsets = NomoInputIter;
|
||||
|
||||
type Checkpoint = NomoInput;
|
||||
type Checkpoint = NomoInputCheckpoint;
|
||||
|
||||
fn iter_offsets(&self) -> Self::IterOffsets {
|
||||
NomoInputIter {
|
||||
|
|
@ -167,7 +188,9 @@ impl Stream for NomoInput {
|
|||
}
|
||||
|
||||
fn checkpoint(&self) -> Self::Checkpoint {
|
||||
self.clone()
|
||||
NomoInputCheckpoint {
|
||||
range: self.get_range(),
|
||||
}
|
||||
}
|
||||
|
||||
fn reset(&mut self, checkpoint: &Self::Checkpoint) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue