aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-06-25 23:14:21 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2024-06-25 23:14:21 +0100
commit1fb575b5ca646581d715c169b24515b51c724b70 (patch)
tree4bdbb65f97559a09b41a7a261a0fb65f8f2e2c01 /src/parser.rs
parentb9d88e5c6f81fadcb4bcceb3326383fc2fb13eb5 (diff)
downloadpeanuts-1fb575b5ca646581d715c169b24515b51c724b70.tar.gz
peanuts-1fb575b5ca646581d715c169b24515b51c724b70.tar.bz2
peanuts-1fb575b5ca646581d715c169b24515b51c724b70.zip
change privacy
Diffstat (limited to '')
-rw-r--r--src/parser.rs233
1 files changed, 127 insertions, 106 deletions
diff --git a/src/parser.rs b/src/parser.rs
index a37fc17..0e2bb90 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -19,13 +19,13 @@ use nom::{
// output is a rust representation of the input xml
// types could be used for xml production too?
-type Document<'s> = (Prolog<'s>, Element<'s>, Vec<Misc<'s>>);
+pub type Document<'s> = (Prolog<'s>, Element<'s>, Vec<Misc<'s>>);
/// [1] document ::= prolog element Misc*
pub fn document(input: &str) -> IResult<&str, Document> {
tuple((prolog, element, many0(misc)))(input)
}
-type Char = char;
+pub type Char = char;
/// [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
pub fn xmlchar(input: &str) -> IResult<&str, Char> {
satisfy(
@@ -33,13 +33,13 @@ pub fn xmlchar(input: &str) -> IResult<&str, Char> {
)(input)
}
-type S<'s> = &'s str;
+pub type S<'s> = &'s str;
/// [3] S ::= (#x20 | #x9 | #xD | #xA)+
pub fn s(input: &str) -> IResult<&str, S> {
is_a("\u{20}\u{9}\u{D}\u{A}")(input)
}
-type NameStartChar = char;
+pub type NameStartChar = char;
/// [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]
pub fn name_start_char(input: &str) -> IResult<&str, NameStartChar> {
satisfy(
@@ -47,7 +47,7 @@ pub fn name_start_char(input: &str) -> IResult<&str, NameStartChar> {
)(input)
}
-type NameChar = char;
+pub type NameChar = char;
/// [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
pub fn name_char(input: &str) -> IResult<&str, NameChar> {
alt((
@@ -58,38 +58,38 @@ pub fn name_char(input: &str) -> IResult<&str, NameChar> {
))(input)
}
-type Name<'s> = &'s str;
+pub type Name<'s> = &'s str;
/// [5] Name ::= NameStartChar (NameChar)*
pub fn name(input: &str) -> IResult<&str, Name> {
recognize(pair(name_start_char, many0(name_char)))(input)
}
-type Names<'s> = &'s str;
+pub type Names<'s> = &'s str;
/// [6] Names ::= Name (#x20 Name)*
pub fn names(input: &str) -> IResult<&str, Names> {
recognize(pair(name, many0(pair(char('\u{20}'), name))))(input)
}
-type Nmtoken<'s> = &'s str;
+pub type Nmtoken<'s> = &'s str;
/// [7] Nmtoken ::= (NameChar)+
pub fn nmtoken(input: &str) -> IResult<&str, Nmtoken> {
recognize(many1(name_char))(input)
}
-type Nmtokens<'s> = &'s str;
+pub type Nmtokens<'s> = &'s str;
/// [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
pub fn nmtokens(input: &str) -> IResult<&str, Nmtokens> {
recognize(pair(nmtoken, many0(pair(char('\u{20}'), nmtoken))))(input)
}
-#[derive(Clone)]
-enum LiteralData<'s> {
+#[derive(Clone, Debug)]
+pub enum LiteralData<'s> {
String(&'s str),
PEReference(PEReference<'s>),
Reference(Reference<'s>),
}
-type EntityValue<'s> = Vec<LiteralData<'s>>;
+pub type EntityValue<'s> = Vec<LiteralData<'s>>;
/// [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"'
/// | "'" ([^%&'] | PEReference | Reference)* "'"
pub fn entity_value(input: &str) -> IResult<&str, EntityValue> {
@@ -125,7 +125,7 @@ pub fn entity_value(input: &str) -> IResult<&str, EntityValue> {
))(input)
}
-type AttValue<'s> = Vec<LiteralData<'s>>;
+pub type AttValue<'s> = Vec<LiteralData<'s>>;
/// [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
/// | "'" ([^<&'] | Reference)* "'"
pub fn att_value(input: &str) -> IResult<&str, AttValue> {
@@ -155,7 +155,7 @@ pub fn att_value(input: &str) -> IResult<&str, AttValue> {
))(input)
}
-type SystemLiteral<'s> = &'s str;
+pub type SystemLiteral<'s> = &'s str;
/// [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
pub fn system_literal(input: &str) -> IResult<&str, SystemLiteral> {
alt((
@@ -164,7 +164,7 @@ pub fn system_literal(input: &str) -> IResult<&str, SystemLiteral> {
))(input)
}
-type PubidLiteral<'s> = &'s str;
+pub type PubidLiteral<'s> = &'s str;
/// [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
pub fn pubid_literal(input: &str) -> IResult<&str, PubidLiteral> {
alt((
@@ -177,7 +177,7 @@ pub fn pubid_literal(input: &str) -> IResult<&str, PubidLiteral> {
))(input)
}
-type PubidChar<'s> = char;
+pub type PubidChar<'s> = char;
/// [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
pub fn pubid_char(input: &str) -> IResult<&str, PubidChar> {
satisfy(|c| matches!(c, '\u{20}' | '\u{D}' | '\u{A}' | 'a'..='z' | 'A'..='Z' | '0'..='9'))(
@@ -185,7 +185,7 @@ pub fn pubid_char(input: &str) -> IResult<&str, PubidChar> {
)
}
-type CharData<'s> = &'s str;
+pub type CharData<'s> = &'s str;
/// [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
pub fn char_data(input: &str) -> IResult<&str, CharData> {
recognize(many_till(
@@ -216,7 +216,7 @@ pub fn char_data(input: &str) -> IResult<&str, CharData> {
// take_till(|c| c == '<' || c == '&').and_then(take_until("]]>"))(input)
}
-type Comment<'s> = &'s str;
+pub type Comment<'s> = &'s str;
/// Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
pub fn comment(input: &str) -> IResult<&str, Comment> {
delimited(
@@ -226,8 +226,8 @@ pub fn comment(input: &str) -> IResult<&str, Comment> {
)(input)
}
-#[derive(Clone)]
-struct PI<'s> {
+#[derive(Clone, Debug)]
+pub struct PI<'s> {
target: &'s str,
instruction: Option<&'s str>,
}
@@ -249,7 +249,7 @@ pub fn pi(input: &str) -> IResult<&str, PI> {
)(input)
}
-type PITarget<'s> = &'s str;
+pub type PITarget<'s> = &'s str;
/// [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
pub fn pi_target(input: &str) -> IResult<&str, PITarget> {
let (rest, name) = name(input)?;
@@ -264,31 +264,31 @@ pub fn pi_target(input: &str) -> IResult<&str, PITarget> {
}
}
-type CDSect<'s> = (CDStart<'s>, CData<'s>, CDEnd<'s>);
+pub type CDSect<'s> = (CDStart<'s>, CData<'s>, CDEnd<'s>);
/// [18] CDSect ::= CDStart CData CDEnd
pub fn cd_sect(input: &str) -> IResult<&str, CDSect> {
tuple((cd_start, cdata, cd_end))(input)
}
-type CDStart<'s> = &'s str;
+pub type CDStart<'s> = &'s str;
/// [19] CDStart ::= '<![CDATA['
pub fn cd_start(input: &str) -> IResult<&str, CDStart> {
tag("<![CDATA[")(input)
}
-type CData<'s> = &'s str;
+pub type CData<'s> = &'s str;
/// [20] CData ::= (Char* - (Char* ']]>' Char*))
pub fn cdata(input: &str) -> IResult<&str, CData> {
recognize(many_till(xmlchar, peek(tag("]]>"))))(input)
}
-type CDEnd<'s> = &'s str;
+pub type CDEnd<'s> = &'s str;
/// [21] CDEnd ::= ']]>'
pub fn cd_end(input: &str) -> IResult<&str, CDEnd> {
tag("]]>")(input)
}
-type Prolog<'s> = (
+pub type Prolog<'s> = (
Option<XMLDecl<'s>>,
Vec<Misc<'s>>,
Option<(DoctypeDecl<'s>, Vec<Misc<'s>>)>,
@@ -302,7 +302,8 @@ pub fn prolog(input: &str) -> IResult<&str, Prolog> {
))(input)
}
-struct XMLDecl<'s> {
+#[derive(Debug)]
+pub struct XMLDecl<'s> {
version_info: VersionInfo,
encoding_decl: Option<EncodingDecl<'s>>,
sd_decl: Option<SDDecl>,
@@ -323,7 +324,7 @@ pub fn xml_decl(input: &str) -> IResult<&str, XMLDecl> {
)(input)
}
-type VersionInfo = VersionNum;
+pub type VersionInfo = VersionNum;
/// [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
pub fn version_info(input: &str) -> IResult<&str, VersionInfo> {
preceded(
@@ -340,8 +341,8 @@ pub fn eq(input: &str) -> IResult<&str, &str> {
recognize(tuple((opt(s), char('='), opt(s))))(input)
}
-#[derive(Clone)]
-enum VersionNum {
+#[derive(Clone, Debug)]
+pub enum VersionNum {
One,
OneDotOne,
}
@@ -356,8 +357,8 @@ pub fn version_num(input: &str) -> IResult<&str, VersionNum> {
)(input)
}
-#[derive(Clone)]
-enum Misc<'s> {
+#[derive(Clone, Debug)]
+pub enum Misc<'s> {
Comment(Comment<'s>),
PI(PI<'s>),
// TODO: how to deal with whitespace
@@ -372,7 +373,8 @@ pub fn misc(input: &str) -> IResult<&str, Misc> {
))(input)
}
-struct DoctypeDecl<'s> {
+#[derive(Debug)]
+pub struct DoctypeDecl<'s> {
name: &'s str,
external_id: Option<ExternalID<'s>>,
int_subset: Option<IntSubset<'s>>,
@@ -403,8 +405,8 @@ pub fn doctypedecl(input: &str) -> IResult<&str, DoctypeDecl> {
)(input)
}
-#[derive(Clone)]
-enum DeclSep<'s> {
+#[derive(Clone, Debug)]
+pub enum DeclSep<'s> {
PEReference(PEReference<'s>),
// TODO: tackle whitespace
S,
@@ -419,7 +421,8 @@ pub fn decl_sep(input: &str) -> IResult<&str, DeclSep> {
))(input)
}
-enum IntSubsetDeclaration<'s> {
+#[derive(Debug)]
+pub enum IntSubsetDeclaration<'s> {
MarkupDecl(MarkupDecl<'s>),
DeclSep(DeclSep<'s>),
}
@@ -434,7 +437,8 @@ pub fn int_subset(input: &str) -> IResult<&str, IntSubset> {
)))(input)
}
-enum MarkupDecl<'s> {
+#[derive(Debug)]
+pub enum MarkupDecl<'s> {
Elementdecl(Elementdecl<'s>),
AttlistDecl(AttlistDecl<'s>),
EntityDecl(EntityDecl<'s>),
@@ -462,7 +466,7 @@ pub fn markup_decl(input: &str) -> IResult<&str, MarkupDecl> {
))(input)
}
-struct ExtSubset<'s> {
+pub struct ExtSubset<'s> {
text_decl: Option<TextDecl<'s>>,
ext_subset_decl: ExtSubsetDecl<'s>,
}
@@ -477,7 +481,7 @@ pub fn ext_subset(input: &str) -> IResult<&str, ExtSubset> {
)(input)
}
-enum ExtSubsetDeclaration<'s> {
+pub enum ExtSubsetDeclaration<'s> {
MarkupDecl(MarkupDecl<'s>),
ConditionalSect(ConditionalSect<'s>),
DeclSep(DeclSep<'s>),
@@ -496,7 +500,7 @@ pub fn ext_subset_decl(input: &str) -> IResult<&str, ExtSubsetDecl> {
)))(input)
}
-type SDDecl = bool;
+pub type SDDecl = bool;
/// [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
pub fn sd_decl(input: &str) -> IResult<&str, SDDecl> {
preceded(
@@ -518,7 +522,8 @@ pub fn sd_decl(input: &str) -> IResult<&str, SDDecl> {
// (Productions 33 through 38 have been removed.)
-enum Element<'s> {
+#[derive(Debug)]
+pub enum Element<'s> {
Empty(EmptyElemTag<'s>),
NotEmpty(STag<'s>, Content<'s>, ETag<'s>),
}
@@ -534,7 +539,8 @@ pub fn element(input: &str) -> IResult<&str, Element> {
))(input)
}
-struct STag<'s> {
+#[derive(Debug)]
+pub struct STag<'s> {
name: Name<'s>,
attributes: Vec<Attribute<'s>>,
}
@@ -550,13 +556,14 @@ pub fn s_tag(input: &str) -> IResult<&str, STag> {
)(input)
}
-type Attribute<'s> = (Name<'s>, AttValue<'s>);
+pub type Attribute<'s> = (Name<'s>, AttValue<'s>);
/// [41] Attribute ::= Name Eq AttValue
pub fn attribute(input: &str) -> IResult<&str, Attribute> {
separated_pair(name, eq, att_value)(input)
}
-struct ETag<'s> {
+#[derive(Debug)]
+pub struct ETag<'s> {
name: Name<'s>,
}
/// [42] ETag ::= '</' Name S? '>'
@@ -566,7 +573,8 @@ pub fn e_tag(input: &str) -> IResult<&str, ETag> {
})(input)
}
-enum ContentItem<'s> {
+#[derive(Debug)]
+pub enum ContentItem<'s> {
// CharData(&'s str),
Element(Element<'s>),
Reference(Reference<'s>),
@@ -574,7 +582,8 @@ enum ContentItem<'s> {
PI(PI<'s>),
Comment(Comment<'s>),
}
-struct Content<'s> {
+#[derive(Debug)]
+pub struct Content<'s> {
char_data: Option<CharData<'s>>,
content: Vec<(ContentItem<'s>, Option<CharData<'s>>)>,
}
@@ -598,7 +607,8 @@ pub fn content(input: &str) -> IResult<&str, Content> {
)(input)
}
-struct EmptyElemTag<'s> {
+#[derive(Debug)]
+pub struct EmptyElemTag<'s> {
name: Name<'s>,
attributes: Vec<Attribute<'s>>,
}
@@ -614,7 +624,8 @@ pub fn empty_elem_tag(input: &str) -> IResult<&str, EmptyElemTag> {
)(input)
}
-struct Elementdecl<'s> {
+#[derive(Debug)]
+pub struct Elementdecl<'s> {
name: Name<'s>,
contentspec: Contentspec<'s>,
}
@@ -631,8 +642,8 @@ pub fn elementdecl(input: &str) -> IResult<&str, Elementdecl> {
}
// TODO: casings???
-#[derive(Clone)]
-enum Contentspec<'s> {
+#[derive(Clone, Debug)]
+pub enum Contentspec<'s> {
Empty,
Any,
Mixed(Mixed<'s>),
@@ -648,8 +659,8 @@ pub fn contentspec(input: &str) -> IResult<&str, Contentspec> {
))(input)
}
-#[derive(Clone)]
-enum Occurence {
+#[derive(Clone, Debug)]
+pub enum Occurence {
Once,
Optional,
Many0,
@@ -668,13 +679,13 @@ pub fn occurence(input: &str) -> IResult<&str, Occurence> {
)(input)
}
-#[derive(Clone)]
-enum ChildrenKind<'s> {
+#[derive(Clone, Debug)]
+pub enum ChildrenKind<'s> {
Choice(Choice<'s>),
Seq(Seq<'s>),
}
-#[derive(Clone)]
-struct Children<'s> {
+#[derive(Clone, Debug)]
+pub struct Children<'s> {
kind: ChildrenKind<'s>,
occurence: Occurence,
}
@@ -696,14 +707,14 @@ pub fn children(input: &str) -> IResult<&str, Children> {
// ))(input)
}
-#[derive(Clone)]
-enum CpKind<'s> {
+#[derive(Clone, Debug)]
+pub enum CpKind<'s> {
Name(Name<'s>),
Choice(Choice<'s>),
Seq(Seq<'s>),
}
-#[derive(Clone)]
-struct Cp<'s> {
+#[derive(Clone, Debug)]
+pub struct Cp<'s> {
kind: CpKind<'s>,
occurence: Occurence,
}
@@ -722,8 +733,8 @@ pub fn cp(input: &str) -> IResult<&str, Cp> {
)(input)
}
-#[derive(Clone)]
-struct Choice<'s>(Vec<Cp<'s>>);
+#[derive(Clone, Debug)]
+pub struct Choice<'s>(Vec<Cp<'s>>);
/// [49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'
pub fn choice(input: &str) -> IResult<&str, Choice> {
map(
@@ -739,8 +750,8 @@ pub fn choice(input: &str) -> IResult<&str, Choice> {
)(input)
}
-#[derive(Clone)]
-struct Seq<'s>(Vec<Cp<'s>>);
+#[derive(Clone, Debug)]
+pub struct Seq<'s>(Vec<Cp<'s>>);
/// [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
pub fn seq(input: &str) -> IResult<&str, Seq> {
map(
@@ -757,8 +768,8 @@ pub fn seq(input: &str) -> IResult<&str, Seq> {
}
// always contains #PCDATA
-#[derive(Clone)]
-struct Mixed<'s>(Vec<Name<'s>>);
+#[derive(Clone, Debug)]
+pub struct Mixed<'s>(Vec<Name<'s>>);
/// [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'
pub fn mixed(input: &str) -> IResult<&str, Mixed> {
alt((
@@ -777,7 +788,8 @@ pub fn mixed(input: &str) -> IResult<&str, Mixed> {
))(input)
}
-struct AttlistDecl<'s> {
+#[derive(Debug)]
+pub struct AttlistDecl<'s> {
element_type: Name<'s>,
att_defs: Vec<AttDef<'s>>,
}
@@ -796,7 +808,8 @@ pub fn attlist_decl(input: &str) -> IResult<&str, AttlistDecl> {
)(input)
}
-struct AttDef<'s> {
+#[derive(Debug)]
+pub struct AttDef<'s> {
name: Name<'s>,
att_type: AttType<'s>,
default_decl: DefaultDecl<'s>,
@@ -817,8 +830,8 @@ pub fn att_def(input: &str) -> IResult<&str, AttDef> {
)(input)
}
-#[derive(Clone)]
-enum AttType<'s> {
+#[derive(Clone, Debug)]
+pub enum AttType<'s> {
StringType,
TokenizedType(TokenizedType),
EnumeratedType(EnumeratedType<'s>),
@@ -836,14 +849,14 @@ pub fn att_type(input: &str) -> IResult<&str, AttType> {
))(input)
}
-type StringType<'s> = &'s str;
+pub type StringType<'s> = &'s str;
/// [55] StringType ::= 'CDATA'
pub fn string_type(input: &str) -> IResult<&str, StringType> {
tag("CDATA")(input)
}
-#[derive(Clone)]
-enum TokenizedType {
+#[derive(Clone, Debug)]
+pub enum TokenizedType {
ID,
IDRef,
IDRefs,
@@ -868,8 +881,8 @@ pub fn tokenized_type(input: &str) -> IResult<&str, TokenizedType> {
))(input)
}
-#[derive(Clone)]
-enum EnumeratedType<'s> {
+#[derive(Debug, Clone)]
+pub enum EnumeratedType<'s> {
NotationType(NotationType<'s>),
Enumeration(Enumeration<'s>),
}
@@ -885,8 +898,8 @@ pub fn enumerated_type(input: &str) -> IResult<&str, EnumeratedType> {
))(input)
}
-#[derive(Clone)]
-struct NotationType<'s>(Vec<Name<'s>>);
+#[derive(Debug, Clone)]
+pub struct NotationType<'s>(Vec<Name<'s>>);
/// [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
pub fn notation_type(input: &str) -> IResult<&str, NotationType> {
map(
@@ -905,8 +918,8 @@ pub fn notation_type(input: &str) -> IResult<&str, NotationType> {
)(input)
}
-#[derive(Clone)]
-struct Enumeration<'s>(Vec<Nmtoken<'s>>);
+#[derive(Debug, Clone)]
+pub struct Enumeration<'s>(Vec<Nmtoken<'s>>);
/// [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'
pub fn enumeration(input: &str) -> IResult<&str, Enumeration> {
map(
@@ -925,8 +938,8 @@ pub fn enumeration(input: &str) -> IResult<&str, Enumeration> {
)(input)
}
-#[derive(Clone)]
-enum DefaultDecl<'s> {
+#[derive(Debug, Clone)]
+pub enum DefaultDecl<'s> {
Required,
Implied,
Fixed(AttValue<'s>),
@@ -943,7 +956,7 @@ pub fn default_decl(input: &str) -> IResult<&str, DefaultDecl> {
))(input)
}
-enum ConditionalSect<'s> {
+pub enum ConditionalSect<'s> {
IncludeSect(IncludeSect<'s>),
IgnoreSect(IgnoreSect<'s>),
}
@@ -959,7 +972,7 @@ pub fn conditional_sect(input: &str) -> IResult<&str, ConditionalSect> {
))(input)
}
-struct IncludeSect<'s>(ExtSubsetDecl<'s>);
+pub struct IncludeSect<'s>(ExtSubsetDecl<'s>);
/// [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
pub fn include_sect(input: &str) -> IResult<&str, IncludeSect> {
map(
@@ -972,7 +985,7 @@ pub fn include_sect(input: &str) -> IResult<&str, IncludeSect> {
)(input)
}
-struct IgnoreSect<'s>(Vec<IgnoreSectContents<'s>>);
+pub struct IgnoreSect<'s>(Vec<IgnoreSectContents<'s>>);
/// [63] ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
pub fn ignore_sect(input: &str) -> IResult<&str, IgnoreSect> {
map(
@@ -985,7 +998,7 @@ pub fn ignore_sect(input: &str) -> IResult<&str, IgnoreSect> {
)(input)
}
-struct IgnoreSectContents<'s> {
+pub struct IgnoreSectContents<'s> {
// TODO: what the fuck does this mean
ignore: Ignore<'s>,
ignore_list: Vec<(IgnoreSectContents<'s>, Ignore<'s>)>,
@@ -1007,14 +1020,14 @@ pub fn ignore_sect_contents(input: &str) -> IResult<&str, IgnoreSectContents> {
)(input)
}
-type Ignore<'s> = &'s str;
+pub type Ignore<'s> = &'s str;
/// [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)
pub fn ignore(input: &str) -> IResult<&str, Ignore> {
recognize(many_till(xmlchar, peek(alt((tag("<!["), tag("]]>"))))))(input)
}
-#[derive(Clone)]
-enum CharRef<'s> {
+#[derive(Clone, Debug)]
+pub enum CharRef<'s> {
Decimal(&'s str),
Hexadecimal(&'s str),
}
@@ -1039,8 +1052,8 @@ pub fn char_ref(input: &str) -> IResult<&str, CharRef> {
))(input)
}
-#[derive(Clone)]
-enum Reference<'s> {
+#[derive(Clone, Debug)]
+pub enum Reference<'s> {
EntityRef(EntityRef<'s>),
CharRef(CharRef<'s>),
}
@@ -1052,19 +1065,20 @@ pub fn reference(input: &str) -> IResult<&str, Reference> {
))(input)
}
-type EntityRef<'s> = &'s str;
+pub type EntityRef<'s> = &'s str;
/// [68] EntityRef ::= '&' Name ';'
pub fn entity_ref(input: &str) -> IResult<&str, EntityRef> {
delimited(tag("&"), name, tag(";"))(input)
}
-type PEReference<'s> = &'s str;
+pub type PEReference<'s> = &'s str;
/// [69] PEReference ::= '%' Name ';'
pub fn pe_reference(input: &str) -> IResult<&str, PEReference> {
delimited(tag("%"), name, tag(";"))(input)
}
-enum EntityDecl<'s> {
+#[derive(Debug)]
+pub enum EntityDecl<'s> {
GEDecl(GEDecl<'s>),
PEDecl(PEDecl<'s>),
}
@@ -1076,7 +1090,8 @@ pub fn entity_decl(input: &str) -> IResult<&str, EntityDecl> {
))(input)
}
-struct GEDecl<'s> {
+#[derive(Debug)]
+pub struct GEDecl<'s> {
name: Name<'s>,
entity_def: EntityDef<'s>,
}
@@ -1092,7 +1107,8 @@ pub fn ge_decl(input: &str) -> IResult<&str, GEDecl> {
)(input)
}
-struct PEDecl<'s> {
+#[derive(Debug)]
+pub struct PEDecl<'s> {
name: Name<'s>,
pe_def: PEDef<'s>,
}
@@ -1108,7 +1124,8 @@ pub fn pe_decl(input: &str) -> IResult<&str, PEDecl> {
)(input)
}
-enum EntityDef<'s> {
+#[derive(Debug)]
+pub enum EntityDef<'s> {
EntityValue(EntityValue<'s>),
ExternalID {
external_id: ExternalID<'s>,
@@ -1131,7 +1148,8 @@ pub fn entity_def(input: &str) -> IResult<&str, EntityDef> {
))(input)
}
-enum PEDef<'s> {
+#[derive(Debug)]
+pub enum PEDef<'s> {
EntityValue(EntityValue<'s>),
ExternalID(ExternalID<'s>),
}
@@ -1145,7 +1163,8 @@ pub fn pe_def(input: &str) -> IResult<&str, PEDef> {
))(input)
}
-enum ExternalID<'s> {
+#[derive(Debug)]
+pub enum ExternalID<'s> {
SYSTEM {
system_identifier: &'s str,
},
@@ -1175,13 +1194,13 @@ pub fn external_id(input: &str) -> IResult<&str, ExternalID> {
))(input)
}
-type NDataDecl<'s> = &'s str;
+pub type NDataDecl<'s> = &'s str;
/// [76] NDataDecl ::= S 'NDATA' S Name
pub fn ndata_decl(input: &str) -> IResult<&str, NDataDecl> {
preceded(tuple((s, tag("NDATA"), s)), name)(input)
}
-struct TextDecl<'s> {
+pub struct TextDecl<'s> {
version_info: Option<VersionInfo>,
encoding_decl: EncodingDecl<'s>,
}
@@ -1200,7 +1219,7 @@ pub fn text_decl(input: &str) -> IResult<&str, TextDecl> {
)(input)
}
-struct ExtParsedEnt<'s> {
+pub struct ExtParsedEnt<'s> {
text_decl: Option<TextDecl<'s>>,
content: Content<'s>,
}
@@ -1211,7 +1230,7 @@ pub fn ext_parsed_ent(input: &str) -> IResult<&str, ExtParsedEnt> {
})(input)
}
-type EncodingDecl<'s> = EncName<'s>;
+pub type EncodingDecl<'s> = EncName<'s>;
/// [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName
pub fn encoding_decl(input: &str) -> IResult<&str, EncodingDecl> {
preceded(
@@ -1223,7 +1242,7 @@ pub fn encoding_decl(input: &str) -> IResult<&str, EncodingDecl> {
)(input)
}
-type EncName<'s> = &'s str;
+pub type EncName<'s> = &'s str;
/// [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
pub fn enc_name(input: &str) -> IResult<&str, EncName> {
recognize(pair(
@@ -1234,11 +1253,13 @@ pub fn enc_name(input: &str) -> IResult<&str, EncName> {
))(input)
}
-struct NotationDecl<'s> {
+#[derive(Debug)]
+pub struct NotationDecl<'s> {
name: &'s str,
id: NotationDeclID<'s>,
}
-enum NotationDeclID<'s> {
+#[derive(Debug)]
+pub enum NotationDeclID<'s> {
External(ExternalID<'s>),
Public(PublicID<'s>),
}
@@ -1263,7 +1284,7 @@ pub fn notation_decl(input: &str) -> IResult<&str, NotationDecl> {
)(input)
}
-type PublicID<'s> = &'s str;
+pub type PublicID<'s> = &'s str;
/// [83] PublicID ::= 'PUBLIC' S PubidLiteral
pub fn public_id(input: &str) -> IResult<&str, PublicID> {
preceded(pair(tag("PUBLIC"), s), pubid_literal)(input)