pub use scnr2_macro::scanner;
pub mod internals;
pub use crate::internals::{
char_iter::iter_with_position::CharIterWithPosition,
find_matches::{FindMatches, FindMatchesWithPosition},
match_types::Match,
position::{Position, Positions},
scanner_impl::ScannerImpl,
};
pub type Span = core::ops::Range<usize>;
#[derive(Debug, Clone)]
pub enum Transition {
SetMode(usize, usize),
PushMode(usize, usize),
PopMode(usize),
}
impl Transition {
#[inline]
pub fn token_type(&self) -> usize {
match self {
Transition::SetMode(token_type, _)
| Transition::PushMode(token_type, _)
| Transition::PopMode(token_type) => *token_type,
}
}
}
#[derive(Debug)]
pub struct ScannerMode {
pub name: &'static str,
pub transitions: &'static [Transition],
pub dfa: Dfa,
}
#[derive(Debug, Clone)]
pub struct Dfa {
pub states: &'static [DfaState],
}
#[derive(Debug, Clone)]
pub struct DfaState {
pub transitions: &'static [Option<DfaTransition>],
pub accept_data: &'static [AcceptData],
}
#[derive(Debug, Clone)]
pub struct AcceptData {
pub token_type: usize,
pub priority: usize,
pub lookahead: Lookahead,
}
#[derive(Debug, Clone)]
pub enum Lookahead {
None,
Positive(Dfa),
Negative(Dfa),
}
#[derive(Debug, Clone)]
pub struct DfaTransition {
pub to: usize,
}