aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/parser.rs36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 2acd579..d049c5c 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -25,11 +25,6 @@ enum ContentItem<'s> {
type Content<'s> = Option<Vec<ContentItem<'s>>>;
-struct Attribute<'s> {
- key: &'s str,
- value: &'s str,
-}
-
struct DoctypeDecl<'s> {
name: &'s str,
// TODO: doctype declaration parsing
@@ -39,16 +34,6 @@ pub fn doctypedecl(input: &str) -> IResult<&str, DoctypeDecl> {
todo!()
}
-struct Element<'s> {
- name: &'s str,
- attributes: Vec<Attribute<'s>>,
- content: Content<'s>,
-}
-/// Element
-pub fn element(input: &str) -> IResult<&str, Element> {
- todo!()
-}
-
type Document<'s> = (Prolog<'s>, Element<'s>, Vec<Misc<'s>>);
/// [1] document ::= prolog element Misc*
pub fn document(input: &str) -> IResult<&str, Document> {
@@ -388,6 +373,27 @@ pub fn sd_decl(input: &str) -> IResult<&str, SDDecl> {
)(input)
}
+// (Productions 33 through 38 have been removed.)
+
+struct Element<'s> {
+ name: &'s str,
+ attributes: Vec<Attribute<'s>>,
+ content: Content<'s>,
+}
+/// [39] element ::= EmptyElemTag | STag content ETag
+pub fn element(input: &str) -> IResult<&str, Element> {
+ alt((
+ empty_elem_tag,
+ map(tuple((s_tag, content, e_tag)), |(start, content, end)| {}),
+ ))(input)
+}
+
+let
+/// [40] STag ::= '<' Name (S Attribute)* S? '>'
+
+type Attribute<'s> = (&'s str, &'s str)
+/// [41] Attribute ::= Name Eq AttValue
+
pub fn reference(input: &str) -> IResult<&str, char> {
todo!()
}