WIP: element parsing

This commit is contained in:
cel 🌸 2024-06-22 13:41:34 +01:00
parent 3a875666a5
commit feb13be926
1 changed files with 21 additions and 15 deletions

View File

@ -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!()
}