diff options
Diffstat (limited to 'src/xml/parsers.rs')
-rw-r--r-- | src/xml/parsers.rs | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/src/xml/parsers.rs b/src/xml/parsers.rs index 87858a1..79d72b4 100644 --- a/src/xml/parsers.rs +++ b/src/xml/parsers.rs @@ -146,7 +146,14 @@ impl<'s> Parser<'s> for Document<'s> { type Output = Document<'s>; fn parse(input: &'s str) -> IResult<&'s str, Document<'s>> { - tuple((Prolog::parse, Element::parse, many0(Misc::parse)))(input) + map( + tuple((Prolog::parse, Element::parse, many0(Misc::parse))), + |(prolog, element, miscs)| Document { + prolog, + element, + miscs, + }, + )(input) } } @@ -518,11 +525,18 @@ impl<'s> Parser<'s> for Prolog<'s> { type Output = Prolog<'s>; fn parse(input: &'s str) -> IResult<&'s str, Prolog<'s>> { - tuple(( - opt(XMLDecl::parse), - many0(Misc::parse), - opt(tuple((DoctypeDecl::parse, many0(Misc::parse)))), - ))(input) + map( + tuple(( + opt(XMLDecl::parse), + many0(Misc::parse), + opt(tuple((DoctypeDecl::parse, many0(Misc::parse)))), + )), + |(xml_decl, miscs, doctype_decl)| Prolog { + xml_decl, + miscs, + doctype_decl, + }, + )(input) } } @@ -661,14 +675,17 @@ impl<'s> Parser<'s> for IntSubset<'s> { type Output = IntSubset<'s>; fn parse(input: &'s str) -> IResult<&'s str, IntSubset<'s>> { - many0(alt(( - map(MarkupDecl::parse, |markup_decl| { - IntSubsetDeclaration::MarkupDecl(markup_decl) - }), - map(DeclSep::parse, |decl_sep| { - IntSubsetDeclaration::DeclSep(decl_sep) - }), - )))(input) + map( + many0(alt(( + map(MarkupDecl::parse, |markup_decl| { + IntSubsetDeclaration::MarkupDecl(markup_decl) + }), + map(DeclSep::parse, |decl_sep| { + IntSubsetDeclaration::DeclSep(decl_sep) + }), + ))), + |declarations| IntSubset(declarations), + )(input) } } @@ -716,17 +733,20 @@ impl<'s> Parser<'s> for ExtSubsetDecl<'s> { type Output = ExtSubsetDecl<'s>; fn parse(input: &'s str) -> IResult<&'s str, ExtSubsetDecl<'s>> { - many0(alt(( - map(MarkupDecl::parse, |markup_decl| { - ExtSubsetDeclaration::MarkupDecl(markup_decl) - }), - map(ConditionalSect::parse, |conditional_sect| { - ExtSubsetDeclaration::ConditionalSect(conditional_sect) - }), - map(DeclSep::parse, |decl_sep| { - ExtSubsetDeclaration::DeclSep(decl_sep) - }), - )))(input) + map( + many0(alt(( + map(MarkupDecl::parse, |markup_decl| { + ExtSubsetDeclaration::MarkupDecl(markup_decl) + }), + map(ConditionalSect::parse, |conditional_sect| { + ExtSubsetDeclaration::ConditionalSect(conditional_sect) + }), + map(DeclSep::parse, |decl_sep| { + ExtSubsetDeclaration::DeclSep(decl_sep) + }), + ))), + |declarations| ExtSubsetDecl(declarations), + )(input) } } |