Compare commits
2 Commits
32545d8a6a
...
4c235b972e
Author | SHA1 | Date |
---|---|---|
cel 🌸 | 4c235b972e | |
cel 🌸 | e17f2d6876 |
|
@ -4,6 +4,7 @@ use crate::error::Error;
|
|||
|
||||
pub mod composers;
|
||||
pub mod parsers;
|
||||
pub mod parsers_complete;
|
||||
|
||||
/// [1] NSAttName ::= PrefixedAttName | DefaultAttName
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
@ -29,13 +29,17 @@ use super::{
|
|||
TokenizedType, UnprefixedName, VersionInfo, VersionNum, XMLDecl, PI, S,
|
||||
};
|
||||
|
||||
pub trait Parser<'s, T> {
|
||||
fn parse(input: &'s str) -> IResult<&str, T>;
|
||||
pub trait Parser<'s> {
|
||||
type Output;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Self::Output>;
|
||||
}
|
||||
|
||||
/// [1] NSAttName ::= PrefixedAttName | DefaultAttName
|
||||
impl<'s> Parser<'s, NSAttName<'s>> for NSAttName<'s> {
|
||||
fn parse(input: &'s str) -> IResult<&str, NSAttName<'s>> {
|
||||
impl<'s> Parser<'s> for NSAttName<'s> {
|
||||
type Output = NSAttName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Self::Output> {
|
||||
alt((
|
||||
map(PrefixedAttName::parse, |prefixed_att_name| {
|
||||
NSAttName::PrefixedAttName(prefixed_att_name)
|
||||
|
@ -46,7 +50,9 @@ impl<'s> Parser<'s, NSAttName<'s>> for NSAttName<'s> {
|
|||
}
|
||||
|
||||
/// [2] PrefixedAttName ::= 'xmlns:' NCName
|
||||
impl<'s> Parser<'s, PrefixedAttName<'s>> for PrefixedAttName<'s> {
|
||||
impl<'s> Parser<'s> for PrefixedAttName<'s> {
|
||||
type Output = PrefixedAttName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PrefixedAttName<'s>> {
|
||||
map(preceded(tag("xmlns:"), NCName::parse), |nc_name| {
|
||||
PrefixedAttName(nc_name)
|
||||
|
@ -55,7 +61,9 @@ impl<'s> Parser<'s, PrefixedAttName<'s>> for PrefixedAttName<'s> {
|
|||
}
|
||||
|
||||
/// [3] DefaultAttName ::= 'xmlns';
|
||||
impl Parser<'_, DefaultAttName> for DefaultAttName {
|
||||
impl Parser<'_> for DefaultAttName {
|
||||
type Output = DefaultAttName;
|
||||
|
||||
fn parse(input: &str) -> IResult<&str, DefaultAttName> {
|
||||
value(DefaultAttName, tag("xmlns"))(input)
|
||||
}
|
||||
|
@ -63,7 +71,9 @@ impl Parser<'_, DefaultAttName> for DefaultAttName {
|
|||
|
||||
/// [5] Name ::= NameStartChar (NameChar)*
|
||||
/// [4] NCName ::= Name - (Char* ':' Char*)
|
||||
impl<'s> Parser<'s, NCName<'s>> for NCName<'s> {
|
||||
impl<'s> Parser<'s> for NCName<'s> {
|
||||
type Output = NCName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, NCName<'s>> {
|
||||
let (rest, name) = peek(recognize(Name::parse))(input)?;
|
||||
if let Some(char) = name.find(':') {
|
||||
|
@ -75,7 +85,9 @@ impl<'s> Parser<'s, NCName<'s>> for NCName<'s> {
|
|||
}
|
||||
|
||||
/// [7] QName ::= PrefixedName | UnprefixedName
|
||||
impl<'s> Parser<'s, QName<'s>> for QName<'s> {
|
||||
impl<'s> Parser<'s> for QName<'s> {
|
||||
type Output = QName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, QName<'s>> {
|
||||
alt((
|
||||
map(PrefixedName::parse, |prefixed_name| {
|
||||
|
@ -89,7 +101,9 @@ impl<'s> Parser<'s, QName<'s>> for QName<'s> {
|
|||
}
|
||||
|
||||
/// [8] PrefixedName ::= Prefix ':' LocalPart
|
||||
impl<'s> Parser<'s, PrefixedName<'s>> for PrefixedName<'s> {
|
||||
impl<'s> Parser<'s> for PrefixedName<'s> {
|
||||
type Output = PrefixedName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PrefixedName<'s>> {
|
||||
map(
|
||||
separated_pair(Prefix::parse, char(':'), LocalPart::parse),
|
||||
|
@ -99,21 +113,27 @@ impl<'s> Parser<'s, PrefixedName<'s>> for PrefixedName<'s> {
|
|||
}
|
||||
|
||||
/// [9] UnprefixedName ::= LocalPart
|
||||
impl<'s> Parser<'s, UnprefixedName<'s>> for UnprefixedName<'s> {
|
||||
impl<'s> Parser<'s> for UnprefixedName<'s> {
|
||||
type Output = UnprefixedName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, UnprefixedName<'s>> {
|
||||
map(LocalPart::parse, |local_part| UnprefixedName(local_part))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [10] Prefix ::= NCName
|
||||
impl<'s> Parser<'s, Prefix<'s>> for Prefix<'s> {
|
||||
impl<'s> Parser<'s> for Prefix<'s> {
|
||||
type Output = Prefix<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Prefix<'s>> {
|
||||
map(NCName::parse, |nc_name| Prefix(nc_name))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [11] LocalPart ::= NCName
|
||||
impl<'s> Parser<'s, LocalPart<'s>> for LocalPart<'s> {
|
||||
impl<'s> Parser<'s> for LocalPart<'s> {
|
||||
type Output = LocalPart<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, LocalPart<'s>> {
|
||||
map(NCName::parse, |nc_name| LocalPart(nc_name))(input)
|
||||
}
|
||||
|
@ -122,14 +142,18 @@ impl<'s> Parser<'s, LocalPart<'s>> for LocalPart<'s> {
|
|||
// xml spec
|
||||
|
||||
/// [1] document ::= prolog element Misc*
|
||||
impl<'s> Parser<'s, Document<'s>> for Document<'s> {
|
||||
impl<'s> Parser<'s> for Document<'s> {
|
||||
type Output = Document<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Document<'s>> {
|
||||
tuple((Prolog::parse, Element::parse, many0(Misc::parse)))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
|
||||
impl Parser<'_, Char> for Char {
|
||||
impl Parser<'_> for Char {
|
||||
type Output = Char;
|
||||
|
||||
fn parse(input: &str) -> IResult<&str, Char> {
|
||||
map(
|
||||
satisfy(
|
||||
|
@ -141,7 +165,9 @@ impl Parser<'_, Char> for Char {
|
|||
}
|
||||
|
||||
/// [3] S ::= (#x20 | #x9 | #xD | #xA)+
|
||||
impl Parser<'_, S> for S {
|
||||
impl Parser<'_> for S {
|
||||
type Output = S;
|
||||
|
||||
fn parse(input: &str) -> IResult<&str, S> {
|
||||
// TODO?: whitespacing
|
||||
// map(is_a("\u{20}\u{9}\u{D}\u{A}"), |s| S(s))(input)
|
||||
|
@ -150,7 +176,9 @@ impl Parser<'_, S> for S {
|
|||
}
|
||||
|
||||
/// [4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
||||
impl Parser<'_, NameStartChar> for NameStartChar {
|
||||
impl Parser<'_> for NameStartChar {
|
||||
type Output = NameStartChar;
|
||||
|
||||
fn parse(input: &str) -> IResult<&str, NameStartChar> {
|
||||
map(
|
||||
satisfy(
|
||||
|
@ -162,7 +190,9 @@ impl Parser<'_, NameStartChar> for NameStartChar {
|
|||
}
|
||||
|
||||
/// [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
||||
impl Parser<'_, NameChar> for NameChar {
|
||||
impl Parser<'_> for NameChar {
|
||||
type Output = NameChar;
|
||||
|
||||
fn parse(input: &str) -> IResult<&str, NameChar> {
|
||||
map(
|
||||
alt((
|
||||
|
@ -177,7 +207,9 @@ impl Parser<'_, NameChar> for NameChar {
|
|||
}
|
||||
|
||||
/// [5] Name ::= NameStartChar (NameChar)*
|
||||
impl<'s> Parser<'s, Name<'s>> for Name<'s> {
|
||||
impl<'s> Parser<'s> for Name<'s> {
|
||||
type Output = Name<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Name<'s>> {
|
||||
map(
|
||||
recognize(pair(NameStartChar::parse, many0(NameChar::parse))),
|
||||
|
@ -187,7 +219,9 @@ impl<'s> Parser<'s, Name<'s>> for Name<'s> {
|
|||
}
|
||||
|
||||
/// [6] Names ::= Name (#x20 Name)*
|
||||
impl<'s> Parser<'s, Names<'s>> for Names<'s> {
|
||||
impl<'s> Parser<'s> for Names<'s> {
|
||||
type Output = Names<'s>;
|
||||
|
||||
// TODO: fix
|
||||
fn parse(input: &'s str) -> IResult<&str, Names<'s>> {
|
||||
map(
|
||||
|
@ -198,7 +232,9 @@ impl<'s> Parser<'s, Names<'s>> for Names<'s> {
|
|||
}
|
||||
|
||||
/// [7] Nmtoken ::= (NameChar)+
|
||||
impl<'s> Parser<'s, Nmtoken<'s>> for Nmtoken<'s> {
|
||||
impl<'s> Parser<'s> for Nmtoken<'s> {
|
||||
type Output = Nmtoken<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Nmtoken<'s>> {
|
||||
map(recognize(many1(NameChar::parse)), |nmtoken| {
|
||||
Nmtoken(nmtoken)
|
||||
|
@ -207,7 +243,9 @@ impl<'s> Parser<'s, Nmtoken<'s>> for Nmtoken<'s> {
|
|||
}
|
||||
|
||||
/// [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
|
||||
impl<'s> Parser<'s, Nmtokens<'s>> for Nmtokens<'s> {
|
||||
impl<'s> Parser<'s> for Nmtokens<'s> {
|
||||
type Output = Nmtokens<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Nmtokens<'s>> {
|
||||
map(
|
||||
pair(
|
||||
|
@ -221,7 +259,9 @@ impl<'s> Parser<'s, Nmtokens<'s>> for Nmtokens<'s> {
|
|||
|
||||
/// [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"'
|
||||
/// | "'" ([^%&'] | PEReference | Reference)* "'"
|
||||
impl<'s> Parser<'s, EntityValue<'s>> for EntityValue<'s> {
|
||||
impl<'s> Parser<'s> for EntityValue<'s> {
|
||||
type Output = EntityValue<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EntityValue<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -268,7 +308,9 @@ impl<'s> Parser<'s, EntityValue<'s>> for EntityValue<'s> {
|
|||
|
||||
/// [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
|
||||
/// | "'" ([^<&'] | Reference)* "'"
|
||||
impl<'s> Parser<'s, AttValue<'s>> for AttValue<'s> {
|
||||
impl<'s> Parser<'s> for AttValue<'s> {
|
||||
type Output = AttValue<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, AttValue<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -302,7 +344,9 @@ impl<'s> Parser<'s, AttValue<'s>> for AttValue<'s> {
|
|||
}
|
||||
|
||||
/// [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
|
||||
impl<'s> Parser<'s, SystemLiteral<'s>> for SystemLiteral<'s> {
|
||||
impl<'s> Parser<'s> for SystemLiteral<'s> {
|
||||
type Output = SystemLiteral<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, SystemLiteral<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -318,7 +362,9 @@ impl<'s> Parser<'s, SystemLiteral<'s>> for SystemLiteral<'s> {
|
|||
}
|
||||
|
||||
/// [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
|
||||
impl<'s> Parser<'s, PubidLiteral<'s>> for PubidLiteral<'s> {
|
||||
impl<'s> Parser<'s> for PubidLiteral<'s> {
|
||||
type Output = PubidLiteral<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PubidLiteral<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -338,7 +384,9 @@ impl<'s> Parser<'s, PubidLiteral<'s>> for PubidLiteral<'s> {
|
|||
}
|
||||
|
||||
/// [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
||||
impl Parser<'_, PubidChar> for PubidChar {
|
||||
impl Parser<'_> for PubidChar {
|
||||
type Output = PubidChar;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, PubidChar> {
|
||||
map(
|
||||
satisfy(
|
||||
|
@ -350,7 +398,9 @@ impl Parser<'_, PubidChar> for PubidChar {
|
|||
}
|
||||
|
||||
/// [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
|
||||
impl<'s> Parser<'s, CharData<'s>> for CharData<'s> {
|
||||
impl<'s> Parser<'s> for CharData<'s> {
|
||||
type Output = CharData<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, CharData<'s>> {
|
||||
map(
|
||||
recognize(many_till(
|
||||
|
@ -363,7 +413,9 @@ impl<'s> Parser<'s, CharData<'s>> for CharData<'s> {
|
|||
}
|
||||
|
||||
/// Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
|
||||
impl<'s> Parser<'s, Comment<'s>> for Comment<'s> {
|
||||
impl<'s> Parser<'s> for Comment<'s> {
|
||||
type Output = Comment<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Comment<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -377,7 +429,9 @@ impl<'s> Parser<'s, Comment<'s>> for Comment<'s> {
|
|||
}
|
||||
|
||||
/// [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
|
||||
impl<'s> Parser<'s, PI<'s>> for PI<'s> {
|
||||
impl<'s> Parser<'s> for PI<'s> {
|
||||
type Output = PI<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PI<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -400,7 +454,9 @@ impl<'s> Parser<'s, PI<'s>> for PI<'s> {
|
|||
}
|
||||
|
||||
/// [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
|
||||
impl<'s> Parser<'s, PITarget<'s>> for PITarget<'s> {
|
||||
impl<'s> Parser<'s> for PITarget<'s> {
|
||||
type Output = PITarget<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PITarget<'s>> {
|
||||
let (rest, name) = Name::parse(input)?;
|
||||
if name.0.to_lowercase() == "xml" {
|
||||
|
@ -416,7 +472,9 @@ impl<'s> Parser<'s, PITarget<'s>> for PITarget<'s> {
|
|||
}
|
||||
|
||||
/// [18] CDSect ::= CDStart CData CDEnd
|
||||
impl<'s> Parser<'s, CDSect<'s>> for CDSect<'s> {
|
||||
impl<'s> Parser<'s> for CDSect<'s> {
|
||||
type Output = CDSect<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, CDSect<'s>> {
|
||||
map(
|
||||
delimited(CDStart::parse, CData::parse, CDEnd::parse),
|
||||
|
@ -426,14 +484,18 @@ impl<'s> Parser<'s, CDSect<'s>> for CDSect<'s> {
|
|||
}
|
||||
|
||||
/// [19] CDStart ::= '<![CDATA['
|
||||
impl Parser<'_, CDStart> for CDStart {
|
||||
impl Parser<'_> for CDStart {
|
||||
type Output = CDStart;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, CDStart> {
|
||||
value(CDStart, tag("<![CDATA["))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [20] CData ::= (Char* - (Char* ']]>' Char*))
|
||||
impl<'s> Parser<'s, CData<'s>> for CData<'s> {
|
||||
impl<'s> Parser<'s> for CData<'s> {
|
||||
type Output = CData<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, CData<'s>> {
|
||||
map(
|
||||
recognize(many_till(Char::parse, peek(tag("]]>")))),
|
||||
|
@ -443,14 +505,18 @@ impl<'s> Parser<'s, CData<'s>> for CData<'s> {
|
|||
}
|
||||
|
||||
/// [21] CDEnd ::= ']]>'
|
||||
impl Parser<'_, CDEnd> for CDEnd {
|
||||
impl Parser<'_> for CDEnd {
|
||||
type Output = CDEnd;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, CDEnd> {
|
||||
value(CDEnd, tag("]]>"))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
|
||||
impl<'s> Parser<'s, Prolog<'s>> for Prolog<'s> {
|
||||
impl<'s> Parser<'s> for Prolog<'s> {
|
||||
type Output = Prolog<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Prolog<'s>> {
|
||||
tuple((
|
||||
opt(XMLDecl::parse),
|
||||
|
@ -461,7 +527,9 @@ impl<'s> Parser<'s, Prolog<'s>> for Prolog<'s> {
|
|||
}
|
||||
|
||||
/// [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
|
||||
impl<'s> Parser<'s, XMLDecl<'s>> for XMLDecl<'s> {
|
||||
impl<'s> Parser<'s> for XMLDecl<'s> {
|
||||
type Output = XMLDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, XMLDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -483,7 +551,9 @@ impl<'s> Parser<'s, XMLDecl<'s>> for XMLDecl<'s> {
|
|||
}
|
||||
|
||||
/// [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
|
||||
impl Parser<'_, VersionInfo> for VersionInfo {
|
||||
impl Parser<'_> for VersionInfo {
|
||||
type Output = VersionInfo;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, VersionInfo> {
|
||||
preceded(
|
||||
tuple((S::parse, tag("version"), Eq::parse)),
|
||||
|
@ -502,7 +572,9 @@ impl Parser<'_, VersionInfo> for VersionInfo {
|
|||
}
|
||||
|
||||
/// [25] Eq ::= S? '=' S?
|
||||
impl Parser<'_, Eq> for Eq {
|
||||
impl Parser<'_> for Eq {
|
||||
type Output = Eq;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, Eq> {
|
||||
value(
|
||||
Eq,
|
||||
|
@ -512,7 +584,9 @@ impl Parser<'_, Eq> for Eq {
|
|||
}
|
||||
|
||||
/// [26] VersionNum ::= '1.' [0-9]+
|
||||
impl Parser<'_, VersionNum> for VersionNum {
|
||||
impl Parser<'_> for VersionNum {
|
||||
type Output = VersionNum;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, VersionNum> {
|
||||
preceded(
|
||||
tag("1."),
|
||||
|
@ -525,7 +599,9 @@ impl Parser<'_, VersionNum> for VersionNum {
|
|||
}
|
||||
|
||||
/// [27] Misc ::= Comment | PI | S
|
||||
impl<'s> Parser<'s, Misc<'s>> for Misc<'s> {
|
||||
impl<'s> Parser<'s> for Misc<'s> {
|
||||
type Output = Misc<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Misc<'s>> {
|
||||
alt((
|
||||
map(Comment::parse, |comment| Misc::Comment(comment)),
|
||||
|
@ -537,7 +613,9 @@ impl<'s> Parser<'s, Misc<'s>> for Misc<'s> {
|
|||
|
||||
/// [16] doctypedecl ::= '<!DOCTYPE' S QName (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
|
||||
/// [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>'
|
||||
impl<'s> Parser<'s, DoctypeDecl<'s>> for DoctypeDecl<'s> {
|
||||
impl<'s> Parser<'s> for DoctypeDecl<'s> {
|
||||
type Output = DoctypeDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, DoctypeDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -565,7 +643,9 @@ impl<'s> Parser<'s, DoctypeDecl<'s>> for DoctypeDecl<'s> {
|
|||
}
|
||||
|
||||
/// [28a] DeclSep ::= PEReference | S
|
||||
impl<'s> Parser<'s, DeclSep<'s>> for DeclSep<'s> {
|
||||
impl<'s> Parser<'s> for DeclSep<'s> {
|
||||
type Output = DeclSep<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, DeclSep<'s>> {
|
||||
alt((
|
||||
map(PEReference::parse, |pe_reference| {
|
||||
|
@ -577,7 +657,9 @@ impl<'s> Parser<'s, DeclSep<'s>> for DeclSep<'s> {
|
|||
}
|
||||
|
||||
/// [28b] intSubset ::= (markupdecl | DeclSep)*
|
||||
impl<'s> Parser<'s, IntSubset<'s>> for IntSubset<'s> {
|
||||
impl<'s> Parser<'s> for IntSubset<'s> {
|
||||
type Output = IntSubset<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, IntSubset<'s>> {
|
||||
many0(alt((
|
||||
map(MarkupDecl::parse, |markup_decl| {
|
||||
|
@ -591,7 +673,9 @@ impl<'s> Parser<'s, IntSubset<'s>> for IntSubset<'s> {
|
|||
}
|
||||
|
||||
/// [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment
|
||||
impl<'s> Parser<'s, MarkupDecl<'s>> for MarkupDecl<'s> {
|
||||
impl<'s> Parser<'s> for MarkupDecl<'s> {
|
||||
type Output = MarkupDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, MarkupDecl<'s>> {
|
||||
alt((
|
||||
map(Elementdecl::parse, |elementdecl| {
|
||||
|
@ -613,7 +697,9 @@ impl<'s> Parser<'s, MarkupDecl<'s>> for MarkupDecl<'s> {
|
|||
}
|
||||
|
||||
/// [30] extSubset ::= TextDecl? extSubsetDecl
|
||||
impl<'s> Parser<'s, ExtSubset<'s>> for ExtSubset<'s> {
|
||||
impl<'s> Parser<'s> for ExtSubset<'s> {
|
||||
type Output = ExtSubset<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ExtSubset<'s>> {
|
||||
map(
|
||||
pair(opt(TextDecl::parse), ExtSubsetDecl::parse),
|
||||
|
@ -626,7 +712,9 @@ impl<'s> Parser<'s, ExtSubset<'s>> for ExtSubset<'s> {
|
|||
}
|
||||
|
||||
/// [31] extSubsetDecl ::= ( markupdecl | conditionalSect | DeclSep)*
|
||||
impl<'s> Parser<'s, ExtSubsetDecl<'s>> for ExtSubsetDecl<'s> {
|
||||
impl<'s> Parser<'s> for ExtSubsetDecl<'s> {
|
||||
type Output = ExtSubsetDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ExtSubsetDecl<'s>> {
|
||||
many0(alt((
|
||||
map(MarkupDecl::parse, |markup_decl| {
|
||||
|
@ -643,7 +731,9 @@ impl<'s> Parser<'s, ExtSubsetDecl<'s>> for ExtSubsetDecl<'s> {
|
|||
}
|
||||
|
||||
/// [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
|
||||
impl Parser<'_, SDDecl> for SDDecl {
|
||||
impl Parser<'_> for SDDecl {
|
||||
type Output = SDDecl;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, SDDecl> {
|
||||
preceded(
|
||||
tuple((S::parse, tag("standalone"), Eq::parse)),
|
||||
|
@ -672,7 +762,9 @@ impl Parser<'_, SDDecl> for SDDecl {
|
|||
// (Productions 33 through 38 have been removed.)
|
||||
|
||||
/// [39] element ::= EmptyElemTag | STag content ETag
|
||||
impl<'s> Parser<'s, Element<'s>> for Element<'s> {
|
||||
impl<'s> Parser<'s> for Element<'s> {
|
||||
type Output = Element<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Element<'s>> {
|
||||
alt((
|
||||
map(EmptyElemTag::parse, |empty_elem_tag| {
|
||||
|
@ -688,7 +780,9 @@ impl<'s> Parser<'s, Element<'s>> for Element<'s> {
|
|||
|
||||
/// [12] STag ::= '<' QName (S Attribute)* S? '>'
|
||||
/// [40] STag ::= '<' Name (S Attribute)* S? '>'
|
||||
impl<'s> Parser<'s, STag<'s>> for STag<'s> {
|
||||
impl<'s> Parser<'s> for STag<'s> {
|
||||
type Output = STag<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, STag<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -702,7 +796,9 @@ impl<'s> Parser<'s, STag<'s>> for STag<'s> {
|
|||
}
|
||||
|
||||
/// [15] Attribute ::= NSAttName Eq AttValue | QName Eq AttValue
|
||||
impl<'s> Parser<'s, Attribute<'s>> for Attribute<'s> {
|
||||
impl<'s> Parser<'s> for Attribute<'s> {
|
||||
type Output = Attribute<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Attribute<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -724,7 +820,9 @@ impl<'s> Parser<'s, Attribute<'s>> for Attribute<'s> {
|
|||
|
||||
/// [13] ETag ::= '</' QName S? '>'
|
||||
/// [42] ETag ::= '</' Name S? '>'
|
||||
impl<'s> Parser<'s, ETag<'s>> for ETag<'s> {
|
||||
impl<'s> Parser<'s> for ETag<'s> {
|
||||
type Output = ETag<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ETag<'s>> {
|
||||
map(
|
||||
delimited(tag("</"), QName::parse, pair(opt(S::parse), tag(">"))),
|
||||
|
@ -733,7 +831,9 @@ impl<'s> Parser<'s, ETag<'s>> for ETag<'s> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'s> Parser<'s, ContentItem<'s>> for ContentItem<'s> {
|
||||
impl<'s> Parser<'s> for ContentItem<'s> {
|
||||
type Output = ContentItem<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ContentItem<'s>> {
|
||||
alt((
|
||||
map(Element::parse, |element| ContentItem::Element(element)),
|
||||
|
@ -748,7 +848,9 @@ impl<'s> Parser<'s, ContentItem<'s>> for ContentItem<'s> {
|
|||
}
|
||||
|
||||
/// [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)*
|
||||
impl<'s> Parser<'s, Content<'s>> for Content<'s> {
|
||||
impl<'s> Parser<'s> for Content<'s> {
|
||||
type Output = Content<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Content<'s>> {
|
||||
map(
|
||||
pair(
|
||||
|
@ -773,7 +875,9 @@ impl<'s> Parser<'s, Content<'s>> for Content<'s> {
|
|||
|
||||
/// [14] EmptyElemTag ::= '<' QName (S Attribute)* S? '/>'
|
||||
/// [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [WFC: Unique Att Spec]
|
||||
impl<'s> Parser<'s, EmptyElemTag<'s>> for EmptyElemTag<'s> {
|
||||
impl<'s> Parser<'s> for EmptyElemTag<'s> {
|
||||
type Output = EmptyElemTag<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EmptyElemTag<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -788,7 +892,9 @@ impl<'s> Parser<'s, EmptyElemTag<'s>> for EmptyElemTag<'s> {
|
|||
|
||||
/// [17] elementdecl ::= '<!ELEMENT' S QName S contentspec S? '>'
|
||||
/// [45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'
|
||||
impl<'s> Parser<'s, Elementdecl<'s>> for Elementdecl<'s> {
|
||||
impl<'s> Parser<'s> for Elementdecl<'s> {
|
||||
type Output = Elementdecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Elementdecl> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -802,7 +908,9 @@ impl<'s> Parser<'s, Elementdecl<'s>> for Elementdecl<'s> {
|
|||
}
|
||||
|
||||
/// [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
|
||||
impl<'s> Parser<'s, Contentspec<'s>> for Contentspec<'s> {
|
||||
impl<'s> Parser<'s> for Contentspec<'s> {
|
||||
type Output = Contentspec<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Contentspec<'s>> {
|
||||
alt((
|
||||
value(Contentspec::Empty, tag("EMPTY")),
|
||||
|
@ -814,7 +922,9 @@ impl<'s> Parser<'s, Contentspec<'s>> for Contentspec<'s> {
|
|||
}
|
||||
|
||||
/// Occurence ::= ('?' | '*' | '+')?
|
||||
impl Parser<'_, Occurence> for Occurence {
|
||||
impl Parser<'_> for Occurence {
|
||||
type Output = Occurence;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, Occurence> {
|
||||
map(
|
||||
opt(alt((tag("?"), tag("*"), tag("+")))),
|
||||
|
@ -829,7 +939,9 @@ impl Parser<'_, Occurence> for Occurence {
|
|||
}
|
||||
|
||||
/// [47] children ::= (choice | seq) ('?' | '*' | '+')?
|
||||
impl<'s> Parser<'s, Children<'s>> for Children<'s> {
|
||||
impl<'s> Parser<'s> for Children<'s> {
|
||||
type Output = Children<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Children<'s>> {
|
||||
map(
|
||||
pair(
|
||||
|
@ -846,7 +958,9 @@ impl<'s> Parser<'s, Children<'s>> for Children<'s> {
|
|||
|
||||
/// [18] cp ::= (QName | choice | seq) ('?' | '*' | '+')?
|
||||
/// [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
|
||||
impl<'s> Parser<'s, Cp<'s>> for Cp<'s> {
|
||||
impl<'s> Parser<'s> for Cp<'s> {
|
||||
type Output = Cp<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Cp<'s>> {
|
||||
map(
|
||||
pair(
|
||||
|
@ -863,7 +977,9 @@ impl<'s> Parser<'s, Cp<'s>> for Cp<'s> {
|
|||
}
|
||||
|
||||
/// [49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'
|
||||
impl<'s> Parser<'s, Choice<'s>> for Choice<'s> {
|
||||
impl<'s> Parser<'s> for Choice<'s> {
|
||||
type Output = Choice<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Choice<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -886,7 +1002,9 @@ impl<'s> Parser<'s, Choice<'s>> for Choice<'s> {
|
|||
}
|
||||
|
||||
/// [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
|
||||
impl<'s> Parser<'s, Seq<'s>> for Seq<'s> {
|
||||
impl<'s> Parser<'s> for Seq<'s> {
|
||||
type Output = Seq<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Seq<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -910,7 +1028,9 @@ impl<'s> Parser<'s, Seq<'s>> for Seq<'s> {
|
|||
|
||||
/// [19] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'
|
||||
/// [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'
|
||||
impl<'s> Parser<'s, Mixed<'s>> for Mixed<'s> {
|
||||
impl<'s> Parser<'s> for Mixed<'s> {
|
||||
type Output = Mixed<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Mixed<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -940,7 +1060,9 @@ impl<'s> Parser<'s, Mixed<'s>> for Mixed<'s> {
|
|||
|
||||
/// [20] AttlistDecl ::= '<!ATTLIST' S QName AttDef* S? '>'
|
||||
/// [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
|
||||
impl<'s> Parser<'s, AttlistDecl<'s>> for AttlistDecl<'s> {
|
||||
impl<'s> Parser<'s> for AttlistDecl<'s> {
|
||||
type Output = AttlistDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, AttlistDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -958,7 +1080,9 @@ impl<'s> Parser<'s, AttlistDecl<'s>> for AttlistDecl<'s> {
|
|||
|
||||
/// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl
|
||||
/// [53] AttDef ::= S Name S AttType S DefaultDecl
|
||||
impl<'s> Parser<'s, AttDef<'s>> for AttDef<'s> {
|
||||
impl<'s> Parser<'s> for AttDef<'s> {
|
||||
type Output = AttDef<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, AttDef<'s>> {
|
||||
map(
|
||||
tuple((
|
||||
|
@ -984,7 +1108,9 @@ impl<'s> Parser<'s, AttDef<'s>> for AttDef<'s> {
|
|||
}
|
||||
|
||||
/// [54] AttType ::= StringType | TokenizedType | EnumeratedType
|
||||
impl<'s> Parser<'s, AttType<'s>> for AttType<'s> {
|
||||
impl<'s> Parser<'s> for AttType<'s> {
|
||||
type Output = AttType<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, AttType<'s>> {
|
||||
alt((
|
||||
value(AttType::StringType, StringType::parse),
|
||||
|
@ -999,14 +1125,18 @@ impl<'s> Parser<'s, AttType<'s>> for AttType<'s> {
|
|||
}
|
||||
|
||||
/// [55] StringType ::= 'CDATA'
|
||||
impl Parser<'_, StringType> for StringType {
|
||||
impl Parser<'_> for StringType {
|
||||
type Output = StringType;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, StringType> {
|
||||
value(StringType, tag("CDATA"))(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// [56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'
|
||||
impl Parser<'_, TokenizedType> for TokenizedType {
|
||||
impl Parser<'_> for TokenizedType {
|
||||
type Output = TokenizedType;
|
||||
|
||||
fn parse(input: &'_ str) -> IResult<&str, TokenizedType> {
|
||||
alt((
|
||||
value(TokenizedType::ID, tag("ID")),
|
||||
|
@ -1024,7 +1154,9 @@ impl Parser<'_, TokenizedType> for TokenizedType {
|
|||
}
|
||||
|
||||
/// [57] EnumeratedType ::= NotationType | Enumeration
|
||||
impl<'s> Parser<'s, EnumeratedType<'s>> for EnumeratedType<'s> {
|
||||
impl<'s> Parser<'s> for EnumeratedType<'s> {
|
||||
type Output = EnumeratedType<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EnumeratedType<'s>> {
|
||||
alt((
|
||||
map(NotationType::parse, |notation_type| {
|
||||
|
@ -1038,7 +1170,9 @@ impl<'s> Parser<'s, EnumeratedType<'s>> for EnumeratedType<'s> {
|
|||
}
|
||||
|
||||
/// [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
|
||||
impl<'s> Parser<'s, NotationType<'s>> for NotationType<'s> {
|
||||
impl<'s> Parser<'s> for NotationType<'s> {
|
||||
type Output = NotationType<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, NotationType<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1061,7 +1195,9 @@ impl<'s> Parser<'s, NotationType<'s>> for NotationType<'s> {
|
|||
}
|
||||
|
||||
/// [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
|
||||
impl<'s> Parser<'s, Enumeration<'s>> for Enumeration<'s> {
|
||||
impl<'s> Parser<'s> for Enumeration<'s> {
|
||||
type Output = Enumeration<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Enumeration<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1084,7 +1220,9 @@ impl<'s> Parser<'s, Enumeration<'s>> for Enumeration<'s> {
|
|||
}
|
||||
|
||||
/// [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
|
||||
impl<'s> Parser<'s, DefaultDecl<'s>> for DefaultDecl<'s> {
|
||||
impl<'s> Parser<'s> for DefaultDecl<'s> {
|
||||
type Output = DefaultDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, DefaultDecl<'s>> {
|
||||
alt((
|
||||
value(DefaultDecl::Required, tag("#REQUIRED")),
|
||||
|
@ -1098,7 +1236,9 @@ impl<'s> Parser<'s, DefaultDecl<'s>> for DefaultDecl<'s> {
|
|||
}
|
||||
|
||||
/// [61] conditionalSect ::= includeSect | ignoreSect
|
||||
impl<'s> Parser<'s, ConditionalSect<'s>> for ConditionalSect<'s> {
|
||||
impl<'s> Parser<'s> for ConditionalSect<'s> {
|
||||
type Output = ConditionalSect<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ConditionalSect<'s>> {
|
||||
alt((
|
||||
map(IncludeSect::parse, |include_sect| {
|
||||
|
@ -1112,7 +1252,9 @@ impl<'s> Parser<'s, ConditionalSect<'s>> for ConditionalSect<'s> {
|
|||
}
|
||||
|
||||
/// [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
|
||||
impl<'s> Parser<'s, IncludeSect<'s>> for IncludeSect<'s> {
|
||||
impl<'s> Parser<'s> for IncludeSect<'s> {
|
||||
type Output = IncludeSect<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, IncludeSect<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1132,7 +1274,9 @@ impl<'s> Parser<'s, IncludeSect<'s>> for IncludeSect<'s> {
|
|||
}
|
||||
|
||||
/// [63] ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
|
||||
impl<'s> Parser<'s, IgnoreSect<'s>> for IgnoreSect<'s> {
|
||||
impl<'s> Parser<'s> for IgnoreSect<'s> {
|
||||
type Output = IgnoreSect<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, IgnoreSect<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1152,7 +1296,9 @@ impl<'s> Parser<'s, IgnoreSect<'s>> for IgnoreSect<'s> {
|
|||
}
|
||||
|
||||
/// [64] ignoreSectContents ::= Ignore ('<![' ignoreSectContents ']]>' Ignore)*
|
||||
impl<'s> Parser<'s, IgnoreSectContents<'s>> for IgnoreSectContents<'s> {
|
||||
impl<'s> Parser<'s> for IgnoreSectContents<'s> {
|
||||
type Output = IgnoreSectContents<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, IgnoreSectContents<'s>> {
|
||||
map(
|
||||
pair(
|
||||
|
@ -1171,7 +1317,9 @@ impl<'s> Parser<'s, IgnoreSectContents<'s>> for IgnoreSectContents<'s> {
|
|||
}
|
||||
|
||||
/// [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)
|
||||
impl<'s> Parser<'s, Ignore<'s>> for Ignore<'s> {
|
||||
impl<'s> Parser<'s> for Ignore<'s> {
|
||||
type Output = Ignore<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Ignore<'s>> {
|
||||
map(
|
||||
recognize(many_till(Char::parse, peek(alt((tag("<!["), tag("]]>")))))),
|
||||
|
@ -1181,7 +1329,9 @@ impl<'s> Parser<'s, Ignore<'s>> for Ignore<'s> {
|
|||
}
|
||||
|
||||
/// [66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
|
||||
impl<'s> Parser<'s, CharRef<'s>> for CharRef<'s> {
|
||||
impl<'s> Parser<'s> for CharRef<'s> {
|
||||
type Output = CharRef<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, CharRef<'s>> {
|
||||
alt((
|
||||
delimited(
|
||||
|
@ -1204,7 +1354,9 @@ impl<'s> Parser<'s, CharRef<'s>> for CharRef<'s> {
|
|||
}
|
||||
|
||||
/// [67] Reference ::= EntityRef | CharRef
|
||||
impl<'s> Parser<'s, Reference<'s>> for Reference<'s> {
|
||||
impl<'s> Parser<'s> for Reference<'s> {
|
||||
type Output = Reference<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, Reference<'s>> {
|
||||
alt((
|
||||
map(EntityRef::parse, |entity_ref| {
|
||||
|
@ -1216,7 +1368,9 @@ impl<'s> Parser<'s, Reference<'s>> for Reference<'s> {
|
|||
}
|
||||
|
||||
/// [68] EntityRef ::= '&' Name ';'
|
||||
impl<'s> Parser<'s, EntityRef<'s>> for EntityRef<'s> {
|
||||
impl<'s> Parser<'s> for EntityRef<'s> {
|
||||
type Output = EntityRef<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EntityRef<'s>> {
|
||||
map(delimited(tag("&"), Name::parse, tag(";")), |entity_ref| {
|
||||
EntityRef(entity_ref)
|
||||
|
@ -1225,7 +1379,9 @@ impl<'s> Parser<'s, EntityRef<'s>> for EntityRef<'s> {
|
|||
}
|
||||
|
||||
/// [69] PEReference ::= '%' Name ';'
|
||||
impl<'s> Parser<'s, PEReference<'s>> for PEReference<'s> {
|
||||
impl<'s> Parser<'s> for PEReference<'s> {
|
||||
type Output = PEReference<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PEReference<'s>> {
|
||||
map(delimited(tag("%"), Name::parse, tag(";")), |pe_reference| {
|
||||
PEReference(pe_reference)
|
||||
|
@ -1234,7 +1390,9 @@ impl<'s> Parser<'s, PEReference<'s>> for PEReference<'s> {
|
|||
}
|
||||
|
||||
/// [70] EntityDecl ::= GEDecl | PEDecl
|
||||
impl<'s> Parser<'s, EntityDecl<'s>> for EntityDecl<'s> {
|
||||
impl<'s> Parser<'s> for EntityDecl<'s> {
|
||||
type Output = EntityDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EntityDecl<'s>> {
|
||||
alt((
|
||||
map(GEDecl::parse, |ge_decl| EntityDecl::GEDecl(ge_decl)),
|
||||
|
@ -1244,7 +1402,9 @@ impl<'s> Parser<'s, EntityDecl<'s>> for EntityDecl<'s> {
|
|||
}
|
||||
|
||||
/// [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
|
||||
impl<'s> Parser<'s, GEDecl<'s>> for GEDecl<'s> {
|
||||
impl<'s> Parser<'s> for GEDecl<'s> {
|
||||
type Output = GEDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, GEDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1258,7 +1418,9 @@ impl<'s> Parser<'s, GEDecl<'s>> for GEDecl<'s> {
|
|||
}
|
||||
|
||||
/// [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
|
||||
impl<'s> Parser<'s, PEDecl<'s>> for PEDecl<'s> {
|
||||
impl<'s> Parser<'s> for PEDecl<'s> {
|
||||
type Output = PEDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PEDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1272,7 +1434,9 @@ impl<'s> Parser<'s, PEDecl<'s>> for PEDecl<'s> {
|
|||
}
|
||||
|
||||
/// [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)
|
||||
impl<'s> Parser<'s, EntityDef<'s>> for EntityDef<'s> {
|
||||
impl<'s> Parser<'s> for EntityDef<'s> {
|
||||
type Output = EntityDef<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EntityDef<'s>> {
|
||||
alt((
|
||||
map(EntityValue::parse, |entity_value| {
|
||||
|
@ -1290,7 +1454,9 @@ impl<'s> Parser<'s, EntityDef<'s>> for EntityDef<'s> {
|
|||
}
|
||||
|
||||
/// [74] PEDef ::= EntityValue | ExternalID
|
||||
impl<'s> Parser<'s, PEDef<'s>> for PEDef<'s> {
|
||||
impl<'s> Parser<'s> for PEDef<'s> {
|
||||
type Output = PEDef<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PEDef<'s>> {
|
||||
alt((
|
||||
map(EntityValue::parse, |entity_value| {
|
||||
|
@ -1305,7 +1471,9 @@ impl<'s> Parser<'s, PEDef<'s>> for PEDef<'s> {
|
|||
|
||||
/// [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral
|
||||
// pub fn external_id(input: &str) -> IResult<&str, ExternalID> {
|
||||
impl<'s> Parser<'s, ExternalID<'s>> for ExternalID<'s> {
|
||||
impl<'s> Parser<'s> for ExternalID<'s> {
|
||||
type Output = ExternalID<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ExternalID<'s>> {
|
||||
alt((
|
||||
map(
|
||||
|
@ -1327,7 +1495,9 @@ impl<'s> Parser<'s, ExternalID<'s>> for ExternalID<'s> {
|
|||
}
|
||||
|
||||
/// [76] NDataDecl ::= S 'NDATA' S Name
|
||||
impl<'s> Parser<'s, NDataDecl<'s>> for NDataDecl<'s> {
|
||||
impl<'s> Parser<'s> for NDataDecl<'s> {
|
||||
type Output = NDataDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, NDataDecl<'s>> {
|
||||
map(
|
||||
preceded(tuple((S::parse, tag("NDATA"), S::parse)), Name::parse),
|
||||
|
@ -1337,7 +1507,9 @@ impl<'s> Parser<'s, NDataDecl<'s>> for NDataDecl<'s> {
|
|||
}
|
||||
|
||||
/// [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
|
||||
impl<'s> Parser<'s, TextDecl<'s>> for TextDecl<'s> {
|
||||
impl<'s> Parser<'s> for TextDecl<'s> {
|
||||
type Output = TextDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, TextDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1357,7 +1529,9 @@ impl<'s> Parser<'s, TextDecl<'s>> for TextDecl<'s> {
|
|||
}
|
||||
|
||||
/// [78] extParsedEnt ::= TextDecl? content
|
||||
impl<'s> Parser<'s, ExtParsedEnt<'s>> for ExtParsedEnt<'s> {
|
||||
impl<'s> Parser<'s> for ExtParsedEnt<'s> {
|
||||
type Output = ExtParsedEnt<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, ExtParsedEnt<'s>> {
|
||||
map(
|
||||
pair(opt(TextDecl::parse), Content::parse),
|
||||
|
@ -1367,7 +1541,9 @@ impl<'s> Parser<'s, ExtParsedEnt<'s>> for ExtParsedEnt<'s> {
|
|||
}
|
||||
|
||||
/// [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName
|
||||
impl<'s> Parser<'s, EncodingDecl<'s>> for EncodingDecl<'s> {
|
||||
impl<'s> Parser<'s> for EncodingDecl<'s> {
|
||||
type Output = EncodingDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EncodingDecl<'s>> {
|
||||
map(
|
||||
preceded(
|
||||
|
@ -1383,7 +1559,9 @@ impl<'s> Parser<'s, EncodingDecl<'s>> for EncodingDecl<'s> {
|
|||
}
|
||||
|
||||
/// [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
|
||||
impl<'s> Parser<'s, EncName<'s>> for EncName<'s> {
|
||||
impl<'s> Parser<'s> for EncName<'s> {
|
||||
type Output = EncName<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, EncName<'s>> {
|
||||
map(
|
||||
recognize(pair(
|
||||
|
@ -1398,7 +1576,9 @@ impl<'s> Parser<'s, EncName<'s>> for EncName<'s> {
|
|||
}
|
||||
|
||||
/// [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'
|
||||
impl<'s> Parser<'s, NotationDecl<'s>> for NotationDecl<'s> {
|
||||
impl<'s> Parser<'s> for NotationDecl<'s> {
|
||||
type Output = NotationDecl<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, NotationDecl<'s>> {
|
||||
map(
|
||||
delimited(
|
||||
|
@ -1423,7 +1603,9 @@ impl<'s> Parser<'s, NotationDecl<'s>> for NotationDecl<'s> {
|
|||
}
|
||||
|
||||
/// [83] PublicID ::= 'PUBLIC' S PubidLiteral
|
||||
impl<'s> Parser<'s, PublicID<'s>> for PublicID<'s> {
|
||||
impl<'s> Parser<'s> for PublicID<'s> {
|
||||
type Output = PublicID<'s>;
|
||||
|
||||
fn parse(input: &'s str) -> IResult<&str, PublicID<'s>> {
|
||||
map(
|
||||
preceded(pair(tag("PUBLIC"), S::parse), PubidLiteral::parse),
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue