diff options
author | 2025-04-03 03:09:35 +0100 | |
---|---|---|
committer | 2025-04-03 03:09:35 +0100 | |
commit | 9c561014f3c4278c0991290c898713f8e9c928e8 (patch) | |
tree | 92c60a88b34909387c854c483a3c3f4bc41c27b9 /src/xml/parsers_complete.rs | |
parent | 2b399fb59d17bc127fbcd1533a3c079bc86770e1 (diff) | |
download | peanuts-9c561014f3c4278c0991290c898713f8e9c928e8.tar.gz peanuts-9c561014f3c4278c0991290c898713f8e9c928e8.tar.bz2 peanuts-9c561014f3c4278c0991290c898713f8e9c928e8.zip |
feat: xml logging
Diffstat (limited to '')
-rw-r--r-- | src/xml/parsers_complete.rs | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/src/xml/parsers_complete.rs b/src/xml/parsers_complete.rs index cdc4fed..f18d0ff 100644 --- a/src/xml/parsers_complete.rs +++ b/src/xml/parsers_complete.rs @@ -156,7 +156,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) } } @@ -528,11 +535,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) } } @@ -671,14 +685,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) } } @@ -726,17 +743,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) } } |