diff options
Diffstat (limited to 'src/xml/mod.rs')
-rw-r--r-- | src/xml/mod.rs | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/xml/mod.rs b/src/xml/mod.rs index d22abd6..8df2f41 100644 --- a/src/xml/mod.rs +++ b/src/xml/mod.rs @@ -58,8 +58,9 @@ pub type Document<'s> = (Prolog<'s>, Element<'s>, Vec<Misc<'s>>); pub struct Char(char); /// [3] S ::= (#x20 | #x9 | #xD | #xA)+ +#[derive(Clone)] #[repr(transparent)] -pub struct S<'s>(&'s str); +pub struct 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] #[repr(transparent)] @@ -88,7 +89,7 @@ pub struct Nmtoken<'s>(&'s str); pub struct Nmtokens<'s>(Vec<Nmtoken<'s>>); #[derive(Clone, Debug)] -pub enum LiteralData<'s> { +pub enum EntityValueData<'s> { String(&'s str), PEReference(PEReference<'s>), Reference(Reference<'s>), @@ -96,24 +97,37 @@ pub enum LiteralData<'s> { /// [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' /// | "'" ([^%&'] | PEReference | Reference)* "'" #[derive(Debug)] -#[repr(transparent)] -pub struct EntityValue<'s>(Vec<LiteralData<'s>>); +pub enum EntityValue<'s> { + DoubleQuoted(Vec<EntityValueData<'s>>), + SingleQuoted(Vec<EntityValueData<'s>>), +} +#[derive(Clone, Debug)] +pub enum AttValueData<'s> { + String(&'s str), + Reference(Reference<'s>), +} /// [10] AttValue ::= '"' ([^<&"] | Reference)* '"' /// | "'" ([^<&'] | Reference)* "'" #[derive(Clone, Debug)] -#[repr(transparent)] -pub struct AttValue<'s>(Vec<LiteralData<'s>>); +pub enum AttValue<'s> { + DoubleQuoted(Vec<AttValueData<'s>>), + SingleQuoted(Vec<AttValueData<'s>>), +} /// [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'") #[derive(Debug)] -#[repr(transparent)] -pub struct SystemLiteral<'s>(&'s str); +pub enum SystemLiteral<'s> { + DoubleQuoted(&'s str), + SingleQuoted(&'s str), +} /// [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'" #[derive(Debug)] -#[repr(transparent)] -pub struct PubidLiteral<'s>(&'s str); +pub enum PubidLiteral<'s> { + DoubleQuoted(&'s str), + SingleQuoted(&'s str), +} /// [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] #[repr(transparent)] @@ -176,7 +190,10 @@ pub struct XMLDecl<'s> { /// [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') #[derive(Debug)] -pub struct VersionInfo(VersionNum); +pub enum VersionInfo { + SingleQuoted(VersionNum), + DoubleQuoted(VersionNum), +} /// [25] Eq ::= S? '=' S? #[derive(Clone)] @@ -220,6 +237,7 @@ pub enum IntSubsetDeclaration<'s> { MarkupDecl(MarkupDecl<'s>), DeclSep(DeclSep<'s>), } +/// from [16] intSubset ::= (markupdecl | PEReference | S)* /// [28b] intSubset ::= (markupdecl | DeclSep)* pub type IntSubset<'s> = Vec<IntSubsetDeclaration<'s>>; @@ -249,7 +267,11 @@ pub enum ExtSubsetDeclaration<'s> { type ExtSubsetDecl<'s> = Vec<ExtSubsetDeclaration<'s>>; /// [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) -pub type SDDecl = bool; +#[derive(Debug, Clone)] +pub enum SDDecl { + SingleQuoted(bool), + DoubleQuoted(bool), +} // (Productions 33 through 38 have been removed.) |