Make parser input more complex
This commit is contained in:
parent
f0e1d2b045
commit
6ac19c8989
@ -1,18 +1,15 @@
|
|||||||
mod boxed_parser;
|
mod boxed_parser;
|
||||||
mod named_parser;
|
mod named_parser;
|
||||||
|
mod parser_input;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub use boxed_parser::BoxedParser;
|
pub use boxed_parser::BoxedParser;
|
||||||
pub use named_parser::NamedParser;
|
pub use named_parser::NamedParser;
|
||||||
|
pub use parser_input::ParserInput;
|
||||||
|
|
||||||
pub type ParseResult<I, O, E> = Result<(O, I), E>;
|
pub type ParseResult<I, O, E> = Result<(O, I), E>;
|
||||||
|
|
||||||
pub trait ParserInput: std::fmt::Debug {}
|
|
||||||
|
|
||||||
impl ParserInput for &str {}
|
|
||||||
impl ParserInput for String {}
|
|
||||||
|
|
||||||
pub trait Parser<I, O, E>
|
pub trait Parser<I, O, E>
|
||||||
where
|
where
|
||||||
I: ParserInput,
|
I: ParserInput,
|
||||||
|
11
src/parser/parser_input.rs
Normal file
11
src/parser/parser_input.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pub trait ParserInput: std::fmt::Debug {
|
||||||
|
type Output;
|
||||||
|
fn next_token() -> Self::Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ParserInput for &str {
|
||||||
|
type Output = ();
|
||||||
|
fn next_token() -> Self::Output {
|
||||||
|
()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user