aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-06-22 13:41:34 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2024-06-22 13:41:34 +0100
commitfeb13be926cbfb5204fa651d7c86809e20954f9d (patch)
tree5bea552e8033638c2bac376f34b4f2085eef344e /src
parent3a875666a5a897d92a9c6d92a67867bcae662211 (diff)
downloadpeanuts-feb13be926cbfb5204fa651d7c86809e20954f9d.tar.gz
peanuts-feb13be926cbfb5204fa651d7c86809e20954f9d.tar.bz2
peanuts-feb13be926cbfb5204fa651d7c86809e20954f9d.zip
WIP: element parsing
Diffstat (limited to 'src')
-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!()
}