tamer: xir::parse::ele: Un-nest child parser errors
This will utilize the superstate's error object in place of nested errors, which was the result of the previous composition-based delegation. As you can see, all we had to do was remove the special handling of these errors; the existing delegation setup continues to handle the types properly with no change. The composition continues to work for `*Attr_`. The alternative was to box inner errors, since they're far from the hot code path, but that's clearly unnecessary. To be clear: this is necessary to allow for recursive grammars in `ele_parse` without creating recursive data structures in Rust. DEV-7145main
parent
adf7baf115
commit
4aaf91a9e7
|
@ -575,10 +575,6 @@ macro_rules! ele_parse {
|
|||
),
|
||||
|
||||
Attrs_(crate::xir::parse::AttrParseError<[<$nt AttrsState_>]>),
|
||||
|
||||
$(
|
||||
$ntref([<$ntref Error_>]),
|
||||
)*
|
||||
}
|
||||
|
||||
impl From<crate::xir::parse::AttrParseError<[<$nt AttrsState_>]>>
|
||||
|
@ -591,14 +587,6 @@ macro_rules! ele_parse {
|
|||
}
|
||||
}
|
||||
|
||||
$(
|
||||
impl From<[<$ntref Error_>]> for [<$nt Error_>] {
|
||||
fn from(e: [<$ntref Error_>]) -> Self {
|
||||
[<$nt Error_>]::$ntref(e)
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
impl std::error::Error for [<$nt Error_>] {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
// TODO
|
||||
|
@ -627,9 +615,6 @@ macro_rules! ele_parse {
|
|||
TtQuote::wrap(tok)
|
||||
),
|
||||
Self::Attrs_(e) => std::fmt::Display::fmt(e, f),
|
||||
$(
|
||||
Self::$ntref(e) => std::fmt::Display::fmt(e, f),
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -660,10 +645,6 @@ macro_rules! ele_parse {
|
|||
],
|
||||
|
||||
Self::Attrs_(e) => e.describe(),
|
||||
|
||||
$(
|
||||
Self::$ntref(e) => e.describe(),
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -960,19 +941,8 @@ macro_rules! ele_parse {
|
|||
#[derive(Debug, PartialEq)]
|
||||
$vis enum [<$nt Error_>] {
|
||||
UnexpectedEle_(crate::xir::QName, crate::span::Span),
|
||||
$(
|
||||
$ntref([<$ntref Error_>]),
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
impl From<[<$ntref Error_>]> for [<$nt Error_>] {
|
||||
fn from(e: [<$ntref Error_>]) -> Self {
|
||||
[<$nt Error_>]::$ntref(e)
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
impl std::error::Error for [<$nt Error_>] {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
// TODO
|
||||
|
@ -991,9 +961,6 @@ macro_rules! ele_parse {
|
|||
Self::UnexpectedEle_(qname, _) => {
|
||||
write!(f, "unexpected {}", TtOpenXmlEle::wrap(qname))
|
||||
},
|
||||
$(
|
||||
Self::$ntref(e) => std::fmt::Display::fmt(e, f),
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1021,10 +988,6 @@ macro_rules! ele_parse {
|
|||
name = TtQuote::wrap(qname),
|
||||
)).into()
|
||||
},
|
||||
|
||||
$(
|
||||
Self::$ntref(e) => e.describe(),
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1213,6 +1176,8 @@ macro_rules! ele_parse {
|
|||
}
|
||||
}
|
||||
|
||||
/// Superstate error object representing the union of all
|
||||
/// related parsers' errors.
|
||||
#[derive(Debug, PartialEq)]
|
||||
$vis enum [<$super Error_>] {
|
||||
$(
|
||||
|
|
Loading…
Reference in New Issue