diff --git a/tamer/src/parse.rs b/tamer/src/parse.rs index 681e0697..4139bc45 100644 --- a/tamer/src/parse.rs +++ b/tamer/src/parse.rs @@ -31,7 +31,8 @@ pub mod util; pub use error::{FinalizeError, ParseError}; pub use lower::{ - lowerable, terminal, Lower, LowerIter, LowerSource, ParsedObject, + lowerable, terminal, FromParseError, Lower, LowerIter, LowerSource, + ParsedObject, }; pub use parser::{FinalizedParser, Parsed, ParsedResult, Parser}; pub use state::{ diff --git a/tamer/src/parse/lower.rs b/tamer/src/parse/lower.rs index 322a921e..56d76eb3 100644 --- a/tamer/src/parse/lower.rs +++ b/tamer/src/parse/lower.rs @@ -239,6 +239,16 @@ pub trait WidenedError = Diagnostic + From::Token, ::Error>> + From::Token, ::Error>>; +/// Convenience trait for converting [`From`] a [`ParseError`] for the +/// provided [`ParseState`] `S`. +/// +/// This allows specifying this type in terms of only the [`ParseState`] +/// that is almost certainly already utilized, +/// rather than having to either import more types or use the verbose +/// associated type. +pub trait FromParseError = + From::Token, ::Error>>; + /// A [`ParsedResult`](super::ParsedResult) with a [`WidenedError`]. pub type WidenedParsedResult = Result::Object>, E>; diff --git a/tamer/src/pipeline.rs b/tamer/src/pipeline.rs index f360e649..cf6e12d1 100644 --- a/tamer/src/pipeline.rs +++ b/tamer/src/pipeline.rs @@ -41,21 +41,15 @@ //! see [`Lower`]. use crate::{ - asg::{ - air::{Air, AirAggregate, AirAggregateCtx}, - AsgError, - }, + asg::air::{AirAggregate, AirAggregateCtx}, diagnose::Diagnostic, - obj::xmlo::{ - XmloAirContext, XmloAirError, XmloError, XmloReader, XmloToAir, - XmloToken, - }, + obj::xmlo::{XmloAirContext, XmloReader, XmloToAir, XmloToken}, parse::{ - FinalizeError, Lower, LowerSource, ParseError, Parsed, ParsedObject, - UnknownToken, + FinalizeError, FromParseError, Lower, LowerSource, ParseError, Parsed, + ParsedObject, UnknownToken, }, xir::{ - flat::{PartialXirToXirf, Text, XirToXirfError, XirfToken}, + flat::{PartialXirToXirf, Text}, Error as XirError, Token as XirToken, }, }; @@ -76,10 +70,10 @@ pub fn load_xmlo( ) -> Result<(AirAggregateCtx, XmloAirContext), EO> where EO: From> - + From, XmloError>> - + From> - + From> - + From> + + FromParseError> + + FromParseError + + FromParseError + + FromParseError + From, { // TODO: This entire block is a WIP and will be incrementally