diff --git a/src/combinators/tuple_parser.rs b/src/combinators/tuple_parser.rs index a2cb6f3..0118342 100644 --- a/src/combinators/tuple_parser.rs +++ b/src/combinators/tuple_parser.rs @@ -120,6 +120,146 @@ where } } +impl< + 'a, + TToken, + T1: 'a, + T2: 'a, + T3: 'a, + T4: 'a, + T5: 'a, + T6: 'a, + TContext, + P1, + P2, + P3, + P4, + P5, + P6, + > ParserTuple<'a, TToken, (T1, T2, T3, T4, T5, T6), TContext> for (P1, P2, P3, P4, P5, P6) +where + TToken: Debug + Clone, + P1: Parser<'a, TToken, T1, TContext>, + P2: Parser<'a, TToken, T2, TContext>, + P3: Parser<'a, TToken, T3, TContext>, + P4: Parser<'a, TToken, T4, TContext>, + P5: Parser<'a, TToken, T5, TContext>, + P6: Parser<'a, TToken, T6, TContext>, +{ + fn parse( + &self, + context: Rc>>, + input: &'a [TToken], + ) -> ParserResult<'a, TToken, (T1, T2, T3, T4, T5, T6)> { + let (input, r1) = self.0.parse(context.clone(), input)?; + let (input, r2) = self.1.parse(context.clone(), input)?; + let (input, r3) = self.2.parse(context.clone(), input)?; + let (input, r4) = self.3.parse(context.clone(), input)?; + let (input, r5) = self.4.parse(context.clone(), input)?; + let (input, r6) = self.5.parse(context.clone(), input)?; + + Ok((input, (r1, r2, r3, r4, r5, r6))) + } +} + +impl< + 'a, + TToken, + T1: 'a, + T2: 'a, + T3: 'a, + T4: 'a, + T5: 'a, + T6: 'a, + T7: 'a, + TContext, + P1, + P2, + P3, + P4, + P5, + P6, + P7, + > ParserTuple<'a, TToken, (T1, T2, T3, T4, T5, T6, T7), TContext> + for (P1, P2, P3, P4, P5, P6, P7) +where + TToken: Debug + Clone, + P1: Parser<'a, TToken, T1, TContext>, + P2: Parser<'a, TToken, T2, TContext>, + P3: Parser<'a, TToken, T3, TContext>, + P4: Parser<'a, TToken, T4, TContext>, + P5: Parser<'a, TToken, T5, TContext>, + P6: Parser<'a, TToken, T6, TContext>, + P7: Parser<'a, TToken, T7, TContext>, +{ + fn parse( + &self, + context: Rc>>, + input: &'a [TToken], + ) -> ParserResult<'a, TToken, (T1, T2, T3, T4, T5, T6, T7)> { + let (input, r1) = self.0.parse(context.clone(), input)?; + let (input, r2) = self.1.parse(context.clone(), input)?; + let (input, r3) = self.2.parse(context.clone(), input)?; + let (input, r4) = self.3.parse(context.clone(), input)?; + let (input, r5) = self.4.parse(context.clone(), input)?; + let (input, r6) = self.5.parse(context.clone(), input)?; + let (input, r7) = self.6.parse(context.clone(), input)?; + + Ok((input, (r1, r2, r3, r4, r5, r6, r7))) + } +} + +impl< + 'a, + TToken, + T1: 'a, + T2: 'a, + T3: 'a, + T4: 'a, + T5: 'a, + T6: 'a, + T7: 'a, + T8: 'a, + TContext, + P1, + P2, + P3, + P4, + P5, + P6, + P7, + P8, + > ParserTuple<'a, TToken, (T1, T2, T3, T4, T5, T6, T7, T8), TContext> + for (P1, P2, P3, P4, P5, P6, P7, P8) +where + TToken: Debug + Clone, + P1: Parser<'a, TToken, T1, TContext>, + P2: Parser<'a, TToken, T2, TContext>, + P3: Parser<'a, TToken, T3, TContext>, + P4: Parser<'a, TToken, T4, TContext>, + P5: Parser<'a, TToken, T5, TContext>, + P6: Parser<'a, TToken, T6, TContext>, + P7: Parser<'a, TToken, T7, TContext>, + P8: Parser<'a, TToken, T8, TContext>, +{ + fn parse( + &self, + context: Rc>>, + input: &'a [TToken], + ) -> ParserResult<'a, TToken, (T1, T2, T3, T4, T5, T6, T7, T8)> { + let (input, r1) = self.0.parse(context.clone(), input)?; + let (input, r2) = self.1.parse(context.clone(), input)?; + let (input, r3) = self.2.parse(context.clone(), input)?; + let (input, r4) = self.3.parse(context.clone(), input)?; + let (input, r5) = self.4.parse(context.clone(), input)?; + let (input, r6) = self.5.parse(context.clone(), input)?; + let (input, r7) = self.6.parse(context.clone(), input)?; + let (input, r8) = self.7.parse(context.clone(), input)?; + + Ok((input, (r1, r2, r3, r4, r5, r6, r7, r8))) + } +} + #[cfg(test)] mod test { use super::*;