Reorganized symbols related to position
This commit is contained in:
parent
856bb308d9
commit
b6bef111c1
@ -2,8 +2,9 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::{
|
||||
CollectedSubstring, Keyword, KeywordComparatorIterator, Pos, Predicate, SourceStream,
|
||||
CollectedSubstring, Keyword, KeywordComparatorIterator, Predicate, SourceStream,
|
||||
};
|
||||
use crate::pos::Pos;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub trait StreamConverter_Char<C: Copy> {
|
||||
|
||||
@ -7,15 +7,12 @@ mod ascii;
|
||||
mod converter;
|
||||
pub mod pos;
|
||||
|
||||
use pos::Pos;
|
||||
|
||||
pub trait Predicate<C: Copy> {
|
||||
fn check(&mut self, chr: C) -> bool;
|
||||
}
|
||||
|
||||
pub trait Pos<'pos> {}
|
||||
|
||||
impl Pos<'static> for () {}
|
||||
impl Pos<'static> for usize {}
|
||||
|
||||
pub trait KeywordComparatorIterator<'keyword, C> {
|
||||
fn consume(&mut self, c: C) -> bool;
|
||||
}
|
||||
|
||||
8
src/pos/default_counters/mod.rs
Normal file
8
src/pos/default_counters/mod.rs
Normal file
@ -0,0 +1,8 @@
|
||||
mod index;
|
||||
mod newline;
|
||||
mod noop;
|
||||
|
||||
pub use index::IndexPosCounter;
|
||||
pub use newline::PosLineCol;
|
||||
pub use newline::NewLinePosCounter;
|
||||
pub use noop::NoopPosCounter;
|
||||
@ -1,5 +1,4 @@
|
||||
use crate::Pos;
|
||||
use crate::pos::PosCounter;
|
||||
use crate::pos::{PosCounter, Pos};
|
||||
|
||||
pub struct PosLineCol {
|
||||
pub row: usize,
|
||||
17
src/pos/default_counters/noop.rs
Normal file
17
src/pos/default_counters/noop.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use crate::pos::PosCounter;
|
||||
|
||||
pub struct NoopPosCounter {}
|
||||
|
||||
impl Default for NoopPosCounter {
|
||||
fn default() -> Self {
|
||||
return NoopPosCounter {};
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Copy> PosCounter<'static, C> for NoopPosCounter {
|
||||
type P = ();
|
||||
|
||||
fn update(&mut self, _: C) {}
|
||||
|
||||
fn export(&self) {}
|
||||
}
|
||||
@ -1,19 +1,7 @@
|
||||
use crate::Pos;
|
||||
mod pos;
|
||||
mod pos_counter;
|
||||
|
||||
pub trait PosCounter<'pos, C: Copy> {
|
||||
type P: Pos<'pos>;
|
||||
pub use pos::Pos;
|
||||
pub use pos_counter::PosCounter;
|
||||
|
||||
fn update(&mut self, c: C);
|
||||
|
||||
fn export(&self) -> Self::P;
|
||||
}
|
||||
|
||||
|
||||
mod index;
|
||||
mod newline;
|
||||
mod nop;
|
||||
|
||||
pub use index::IndexPosCounter;
|
||||
pub use newline::PosLineCol;
|
||||
pub use newline::NewLinePosCounter;
|
||||
pub use nop::NopPosCounter;
|
||||
pub mod default_counters;
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
use crate::pos::PosCounter;
|
||||
|
||||
pub struct NopPosCounter {}
|
||||
|
||||
impl Default for NopPosCounter {
|
||||
fn default() -> Self {
|
||||
return NopPosCounter {};
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Copy> PosCounter<'static, C> for NopPosCounter {
|
||||
type P = ();
|
||||
|
||||
fn update(&mut self, _: C) {}
|
||||
|
||||
fn export(&self) {}
|
||||
}
|
||||
4
src/pos/pos.rs
Normal file
4
src/pos/pos.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub trait Pos<'pos> {}
|
||||
|
||||
impl Pos<'static> for () {}
|
||||
impl Pos<'static> for usize {}
|
||||
10
src/pos/pos_counter.rs
Normal file
10
src/pos/pos_counter.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use crate::pos::Pos;
|
||||
|
||||
pub trait PosCounter<'pos, C: Copy> {
|
||||
type P: Pos<'pos>;
|
||||
|
||||
fn update(&mut self, c: C);
|
||||
|
||||
fn export(&self) -> Self::P;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user