summaryrefslogtreecommitdiff
path: root/nfa/src/desrec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'nfa/src/desrec.rs')
-rw-r--r--nfa/src/desrec.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/nfa/src/desrec.rs b/nfa/src/desrec.rs
index c57d313..ac45c2d 100644
--- a/nfa/src/desrec.rs
+++ b/nfa/src/desrec.rs
@@ -20,8 +20,8 @@ pub trait DesRec {
/// The type of errors encountered when parsing.
type Error: std::error::Error;
- /// Auxiliary data when parsing
- type Aux;
+ /// Intermediate data when parsing
+ type Inter;
/// The type of a scanner that classifies inputs into tokens.
///
@@ -34,7 +34,14 @@ pub trait DesRec {
///
/// - `Ok(Some(_))`: the classification succeeds and the parsing
/// should continue.
- type Scanner<'a>: FnMut(&'a str) -> Result<Option<(usize, Self::Label, Self::Aux)>, Self::Error>;
+ type Scanner<'a, 'b>: FnMut(
+ &'b Self,
+ &'a str,
+ )
+ -> Result<Option<(usize, Self::Label, Self::Inter)>, Self::Error>
+ where
+ Self: 'b,
+ Self::Label: 'b;
/// Parse a string into a regular expression with the aid of this
/// type.
@@ -42,9 +49,12 @@ pub trait DesRec {
/// Accept a slice of string and return either a parsing error, or
/// a pair of correctly parsed regular expression and the
/// remaining slice.
- fn parse<'a>(
+ fn parse<'a, 'b>(
+ &'b self,
input: &'a str,
- scanner: Self::Scanner<'a>,
+ scanner: Self::Scanner<'a, 'b>,
post_p: bool,
- ) -> Result<ParseOutput<'a, Self::Regex>, Self::Error>;
+ ) -> Result<ParseOutput<'a, Self::Regex>, Self::Error>
+ where
+ Self::Label: 'b;
}