From 6ac19c8989de3713540017d3ea199b57ef213f77 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 23 Oct 2022 00:41:51 -0700 Subject: [PATCH] Make parser input more complex --- src/parser/mod.rs | 7 ++----- src/parser/parser_input.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 src/parser/parser_input.rs diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 00eb190..e0c8eb3 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,18 +1,15 @@ mod boxed_parser; mod named_parser; +mod parser_input; use std::rc::Rc; pub use boxed_parser::BoxedParser; pub use named_parser::NamedParser; +pub use parser_input::ParserInput; pub type ParseResult = Result<(O, I), E>; -pub trait ParserInput: std::fmt::Debug {} - -impl ParserInput for &str {} -impl ParserInput for String {} - pub trait Parser where I: ParserInput, diff --git a/src/parser/parser_input.rs b/src/parser/parser_input.rs new file mode 100644 index 0000000..0784227 --- /dev/null +++ b/src/parser/parser_input.rs @@ -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 { + () + } +}