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