diff --git a/tamer/src/parse/parser.rs b/tamer/src/parse/parser.rs index cd7b1a96..f0935995 100644 --- a/tamer/src/parse/parser.rs +++ b/tamer/src/parse/parser.rs @@ -85,7 +85,7 @@ pub struct Parser> { /// /// See [`take_lookahead_tok`](Parser::take_lookahead_tok) for more /// information. - lookahead: Option>, + lookahead: Option>, /// Parsing automaton. /// diff --git a/tamer/src/parse/state.rs b/tamer/src/parse/state.rs index 99dbc1b5..e82e1861 100644 --- a/tamer/src/parse/state.rs +++ b/tamer/src/parse/state.rs @@ -249,7 +249,7 @@ pub trait ParseState: PartialEq + Eq + Display + Debug + Sized { Ok(Obj(obj)) => Ok(Obj(obj.into())), Err(e) => Err(e.into()), }, - lookahead.map(|Lookahead(la)| Lookahead(la)), + lookahead, ), ), } @@ -292,10 +292,7 @@ pub trait ParseState: PartialEq + Eq + Display + Debug + Sized { TransitionData::Result(Ok(Obj(obj)), lookahead) => { TransitionResult( into(newst, Some(obj), env), - TransitionData::Result( - Ok(Incomplete), - lookahead.map(|Lookahead(la)| Lookahead(la)), - ), + TransitionData::Result(Ok(Incomplete), lookahead), ) } @@ -306,7 +303,7 @@ pub trait ParseState: PartialEq + Eq + Display + Debug + Sized { Ok(_) => Ok(Incomplete), Err(e) => Err(e.into()), }, - lookahead.map(|Lookahead(la)| Lookahead(la)), + lookahead, ), ), } diff --git a/tamer/src/parse/state/transition.rs b/tamer/src/parse/state/transition.rs index 8d44797f..d1996df2 100644 --- a/tamer/src/parse/state/transition.rs +++ b/tamer/src/parse/state/transition.rs @@ -19,7 +19,7 @@ //! State transitions for parser automata. -use super::{ParseState, ParseStateResult, ParseStatus}; +use super::{ParseState, ParseStateResult, ParseStatus, Token}; use std::{ convert::Infallible, hint::unreachable_unchecked, @@ -27,7 +27,7 @@ use std::{ }; #[cfg(doc)] -use super::{Parser, Token}; +use super::Parser; /// A state transition with associated data. /// @@ -86,7 +86,7 @@ impl TransitionResult { /// Token to use as a lookahead token in place of the next token from the /// input stream. #[derive(Debug, PartialEq)] -pub struct Lookahead(pub(in super::super) S::Token); +pub struct Lookahead(pub(in super::super) T); /// Information about the state transition. /// @@ -103,7 +103,7 @@ pub(in super::super) enum TransitionData { /// successful [`ParseStateResult`]---the /// parser may choose to successfully transition into an error /// recovery state to accommodate future tokens. - Result(ParseStateResult, Option>), + Result(ParseStateResult, Option>), /// No valid state transition exists from the current state for the /// given input token, @@ -124,7 +124,7 @@ pub(in super::super) enum TransitionData { /// and may lead to finalization of the parser. /// If a parser intends to do additional work, /// it should return an error instead via [`TransitionData::Result`]. - Dead(Lookahead), + Dead(Lookahead), } /// A verb denoting a state transition.