change contents of Names and Nmtokens to Vecs
This commit is contained in:
parent
ceb1bca7a4
commit
c6c3c1b403
|
@ -1,5 +1,6 @@
|
||||||
use std::char;
|
use std::char;
|
||||||
|
|
||||||
|
pub mod composers;
|
||||||
pub mod parsers;
|
pub mod parsers;
|
||||||
|
|
||||||
/// [1] NSAttName ::= PrefixedAttName | DefaultAttName
|
/// [1] NSAttName ::= PrefixedAttName | DefaultAttName
|
||||||
|
@ -75,8 +76,7 @@ pub struct Name<'s>(&'s str);
|
||||||
|
|
||||||
/// [6] Names ::= Name (#x20 Name)*
|
/// [6] Names ::= Name (#x20 Name)*
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
// TODO: turn into vec
|
pub struct Names<'s>(Vec<Name<'s>>);
|
||||||
pub struct Names<'s>(&'s str);
|
|
||||||
|
|
||||||
/// [7] Nmtoken ::= (NameChar)+
|
/// [7] Nmtoken ::= (NameChar)+
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -85,8 +85,7 @@ pub struct Nmtoken<'s>(&'s str);
|
||||||
|
|
||||||
/// [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
|
/// [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
// TODO: turn into vec
|
pub struct Nmtokens<'s>(Vec<Nmtoken<'s>>);
|
||||||
pub struct Nmtokens<'s>(&'s str);
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum LiteralData<'s> {
|
pub enum LiteralData<'s> {
|
||||||
|
|
|
@ -189,8 +189,8 @@ impl<'s> Parser<'s, Names<'s>> for Names<'s> {
|
||||||
// TODO: fix
|
// TODO: fix
|
||||||
fn parse(input: &'s str) -> IResult<&str, Names<'s>> {
|
fn parse(input: &'s str) -> IResult<&str, Names<'s>> {
|
||||||
map(
|
map(
|
||||||
recognize(pair(Name::parse, many0(pair(char('\u{20}'), Name::parse)))),
|
pair(Name::parse, many0(preceded(char('\u{20}'), Name::parse))),
|
||||||
|names| Names(names),
|
|(head, tail)| Names(vec![vec![head], tail].concat()),
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,11 +208,11 @@ impl<'s> Parser<'s, Nmtoken<'s>> for Nmtoken<'s> {
|
||||||
impl<'s> Parser<'s, Nmtokens<'s>> for Nmtokens<'s> {
|
impl<'s> Parser<'s, Nmtokens<'s>> for Nmtokens<'s> {
|
||||||
fn parse(input: &'s str) -> IResult<&str, Nmtokens<'s>> {
|
fn parse(input: &'s str) -> IResult<&str, Nmtokens<'s>> {
|
||||||
map(
|
map(
|
||||||
recognize(pair(
|
pair(
|
||||||
Nmtoken::parse,
|
Nmtoken::parse,
|
||||||
many0(pair(char('\u{20}'), Nmtoken::parse)),
|
many0(preceded(char('\u{20}'), Nmtoken::parse)),
|
||||||
)),
|
),
|
||||||
|nmtokens| Nmtokens(nmtokens),
|
|(head, tail)| Nmtokens(vec![vec![head], tail].concat()),
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue