mod _keyword_impls; mod parser_func; mod builder_type_t; pub trait Predicate { 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; } pub trait Keyword<'keyword, C> { fn startComparation( &self, expectedLen: usize, ) -> Option>; } pub trait CollectedSubstring<'source, C> { fn compareKeyword<'keyword>(&self, kw: impl Keyword<'keyword, C>) -> bool; } pub enum CollectResult { EOF, NotMatches, Matches(T), } pub trait SourceStream<'source, 'pos, C, P: Pos<'pos>, CS: CollectedSubstring<'source, C>> { /** * Returns `true` if the end of stream reached. */ fn skip(&mut self, predicate: &mut impl Predicate) -> bool; fn collect(&mut self, predicate: &mut impl Predicate) -> CollectResult; fn pos(&self) -> P; fn currentChar(&self) -> Option; fn nextChar(&mut self) -> Option; fn isEnded(&mut self) -> bool { return self.currentChar().is_none(); } }