WIP: element parsing
This commit is contained in:
		
							parent
							
								
									3a875666a5
								
							
						
					
					
						commit
						feb13be926
					
				| 
						 | 
					@ -25,11 +25,6 @@ enum ContentItem<'s> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Content<'s> = Option<Vec<ContentItem<'s>>>;
 | 
					type Content<'s> = Option<Vec<ContentItem<'s>>>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Attribute<'s> {
 | 
					 | 
				
			||||||
    key: &'s str,
 | 
					 | 
				
			||||||
    value: &'s str,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct DoctypeDecl<'s> {
 | 
					struct DoctypeDecl<'s> {
 | 
				
			||||||
    name: &'s str,
 | 
					    name: &'s str,
 | 
				
			||||||
    // TODO: doctype declaration parsing
 | 
					    // TODO: doctype declaration parsing
 | 
				
			||||||
| 
						 | 
					@ -39,16 +34,6 @@ pub fn doctypedecl(input: &str) -> IResult<&str, DoctypeDecl> {
 | 
				
			||||||
    todo!()
 | 
					    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>>);
 | 
					type Document<'s> = (Prolog<'s>, Element<'s>, Vec<Misc<'s>>);
 | 
				
			||||||
/// [1]   	document	   ::=   	prolog element Misc*
 | 
					/// [1]   	document	   ::=   	prolog element Misc*
 | 
				
			||||||
pub fn document(input: &str) -> IResult<&str, Document> {
 | 
					pub fn document(input: &str) -> IResult<&str, Document> {
 | 
				
			||||||
| 
						 | 
					@ -388,6 +373,27 @@ pub fn sd_decl(input: &str) -> IResult<&str, SDDecl> {
 | 
				
			||||||
    )(input)
 | 
					    )(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> {
 | 
					pub fn reference(input: &str) -> IResult<&str, char> {
 | 
				
			||||||
    todo!()
 | 
					    todo!()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue