@@ -31,6 +31,8 @@ impl<I: Clone, O, A: Parser<I, O, Error = E>, B: Parser<I, O, Error = E>, E: Err
31
31
let a_state = stream. save ( ) ;
32
32
33
33
// If the first parser succeeded and produced no secondary errors, don't bother trying the second parser
34
+ // TODO: Perhaps we should *alwaus* take this route, even if recoverable errors did occur? Seems like an
35
+ // inconsistent application of PEG rules...
34
36
if a_res. 0 . is_empty ( ) {
35
37
if let ( a_errors, Ok ( a_out) ) = a_res {
36
38
return ( a_errors, Ok ( a_out) ) ;
@@ -428,7 +430,7 @@ impl<A, B, U> SeparatedBy<A, B, U> {
428
430
///
429
431
/// ```
430
432
/// # use chumsky::prelude::*;
431
- /// let r#enum = seq:: <_, _, Simple<char>>("enum".chars() )
433
+ /// let r#enum = text::keyword:: <_, _, Simple<char>>("enum")
432
434
/// .padded()
433
435
/// .ignore_then(text::ident()
434
436
/// .padded()
@@ -987,8 +989,9 @@ impl<I: Clone, O, A: Parser<I, O, Error = E>, F: Fn(E) -> E, E: Error<I>> Parser
987
989
let ( errors, res) = debugger. invoke ( & self . 0 , stream) ;
988
990
let mapper = |e : Located < I , E > | e. map ( & self . 1 ) ;
989
991
(
990
- errors, //errors.into_iter().map(mapper).collect(),
991
- res/*.map(|(out, alt)| (out, alt.map(mapper)))*/ . map_err ( mapper) ,
992
+ errors, //errors.into_iter().map(mapper).collect(),
993
+ res /*.map(|(out, alt)| (out, alt.map(mapper)))*/
994
+ . map_err ( mapper) ,
992
995
)
993
996
}
994
997
@@ -1025,14 +1028,14 @@ impl<I: Clone, O, A: Parser<I, O, Error = E>, F: Fn(E, E::Span) -> E, E: Error<I
1025
1028
let mapper = |e : Located < I , E > | {
1026
1029
let at = e. at ;
1027
1030
e. map ( |e| {
1028
- let span = stream. attempt ( |stream| { stream. revert ( at) ; ( false , stream. span_since ( start) ) } ) ;
1031
+ let span = stream. attempt ( |stream| {
1032
+ stream. revert ( at) ;
1033
+ ( false , stream. span_since ( start) )
1034
+ } ) ;
1029
1035
( self . 1 ) ( e, span)
1030
1036
} )
1031
1037
} ;
1032
- (
1033
- errors,
1034
- res. map_err ( mapper) ,
1035
- )
1038
+ ( errors, res. map_err ( mapper) )
1036
1039
}
1037
1040
1038
1041
#[ inline]
@@ -1103,13 +1106,8 @@ impl<
1103
1106
#[ derive( Copy , Clone ) ]
1104
1107
pub struct OrElse < A , F > ( pub ( crate ) A , pub ( crate ) F ) ;
1105
1108
1106
- impl <
1107
- I : Clone ,
1108
- O ,
1109
- A : Parser < I , O , Error = E > ,
1110
- F : Fn ( E ) -> Result < O , E > ,
1111
- E : Error < I > ,
1112
- > Parser < I , O > for OrElse < A , F >
1109
+ impl < I : Clone , O , A : Parser < I , O , Error = E > , F : Fn ( E ) -> Result < O , E > , E : Error < I > > Parser < I , O >
1110
+ for OrElse < A , F >
1113
1111
{
1114
1112
type Error = E ;
1115
1113
@@ -1125,7 +1123,11 @@ impl<
1125
1123
let res = match res {
1126
1124
Ok ( out) => Ok ( out) ,
1127
1125
Err ( err) => match ( & self . 1 ) ( err. error ) {
1128
- Err ( e) => Err ( Located { at : err. at , error : e, phantom : PhantomData } ) ,
1126
+ Err ( e) => Err ( Located {
1127
+ at : err. at ,
1128
+ error : e,
1129
+ phantom : PhantomData ,
1130
+ } ) ,
1129
1131
Ok ( out) => Ok ( ( out, None ) ) ,
1130
1132
} ,
1131
1133
} ;
@@ -1167,8 +1169,8 @@ impl<I: Clone, O, A: Parser<I, O, Error = E>, L: Into<E::Label> + Clone, E: Erro
1167
1169
/* TODO: Not this? */
1168
1170
/*if e.at > pre_state
1169
1171
{*/
1170
- // Only add the label if we committed to this pattern somewhat
1171
- e. map ( |e| e. with_label ( self . 1 . clone ( ) . into ( ) ) )
1172
+ // Only add the label if we committed to this pattern somewhat
1173
+ e. map ( |e| e. with_label ( self . 1 . clone ( ) . into ( ) ) )
1172
1174
/*} else {
1173
1175
e
1174
1176
}*/
0 commit comments