#![warn(missing_docs)]
#![allow(clippy::needless_doctest_main)]
pub mod lexer;
pub mod memo;
pub mod parser;
pub use parse_it_macros::parse_it;
pub use crate::{
lexer::{CharLexer, Cursor, LexerState},
memo::{left_rec, memorize, Memo},
parser::{Error, ParserState},
};
pub trait LexIt {
type Token<'a>;
fn new() -> Self;
fn next<'a>(&self, lexbuf: &mut LexerState<'a>) -> Option<Self::Token<'a>>;
}
pub trait ParseIt {
type Lexer: LexIt + Clone;
type Output;
fn parse_stream<'a>(
&self,
state: &mut ParserState<'a, Self::Lexer>,
) -> Result<Self::Output, Error>;
fn parse(&self, input: &str) -> Result<Self::Output, Error> {
let mut state = ParserState::new(input);
self.parse_stream(&mut state)
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! identity {
($expr:expr) => {
$expr
};
}