You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Potentially borrowing conversion from a pest parse tree.pubtraitFromPest<'pest>:Sized{/// The rule type for the parse tree this type corresponds to.typeRule:RuleType;/// A fatal error during conversion.typeFatalError;/// Convert from a Pest parse tree.////// # Return type semantics////// - `Err(ConversionError::NoMatch)` => node not at head of the cursor, cursor unchanged/// - `Err(ConversionError::Malformed)` => fatal error; node at head of the cursor but malformed/// - `Ok` => success; the cursor has been updated past this nodefnfrom_pest(pest:&mutPairs<'pest,Self::Rule>,) -> Result<Self,ConversionError<Self::FatalError>>;}
Potential changes we might want to make:
Make Rule a parameter to the type rather than an associated type. This enables impl<'pest> FromPest<'pest, Rule> for ForeignType (in theory at least; didn't check).
fn from_pest(..) -> FromPestResult<Self, Self::FatalError>. Either by type alias or making a new Try type. Either way, we should reconsider what we want to be propagated with ?; fatal errors for sure, but what about failed conversions?
The more I work with it, the more I feel like I want the possibility to transfer state through the FromPest plumbing, because I want to have pest-ast derived FromPest implementations to be able to panic more eagerly on bad trees. (Or even have a FatalError mode.) This also makes encoding of precedence climbing more obvious.
Having the default "no conversion" match store context may help as well, but may preclude being able to meaningfully ?-propogate it?
Please point out any flaws and over-engineering of the approach. Though this definitely gives up on sizeof(return) == sizeof(Option<Self>) where FatalError = !, which is a nice property, in order to get useful failure breadcrumbs. Maybe we can do like nom does and have a feature to enable verbose failure modes?
The complexity of this points towards leaving from-pest out of tree from pest for a good deal longer. I don't expect we should try to upstream any of this in the near future; 3.x maybe, 2.y probably not.
The text was updated successfully, but these errors were encountered:
Barring any further suggestions, I'm probably going to do a large refactoring of everything in the second half of December. That will set up for this change, though doesn't require it, and will definitely benefit us either way.
Large chunks of codegen are hard to manage super well.
Currently:
Potential changes we might want to make:
Rule
a parameter to the type rather than an associated type. This enablesimpl<'pest> FromPest<'pest, Rule> for ForeignType
(in theory at least; didn't check).fn from_pest(..) -> FromPestResult<Self, Self::FatalError>
. Either by type alias or making a newTry
type. Either way, we should reconsider what we want to be propagated with?
; fatal errors for sure, but what about failed conversions?FromPest
plumbing, because I want to havepest-ast
derivedFromPest
implementations to be able to panic more eagerly on bad trees. (Or even have aFatalError
mode.) This also makes encoding of precedence climbing more obvious.?
-propogate it?Draft "improved"
FromPest
(using cheat syntax):Please point out any flaws and over-engineering of the approach. Though this definitely gives up on
sizeof(return) == sizeof(Option<Self>) where FatalError = !
, which is a nice property, in order to get useful failure breadcrumbs. Maybe we can do likenom
does and have a feature to enable verbose failure modes?The complexity of this points towards leaving
from-pest
out of tree frompest
for a good deal longer. I don't expect we should try to upstream any of this in the near future; 3.x maybe, 2.y probably not.The text was updated successfully, but these errors were encountered: