require terminator after node_children too

This commit is contained in:
Kat Marchán 2020-12-18 22:53:59 -08:00
parent 2c443aed85
commit 5809d21898
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
1 changed files with 4 additions and 4 deletions

View File

@ -68,13 +68,13 @@ enum NodeArg {
Property(String, KdlValue), Property(String, KdlValue),
} }
/// `node := ('/-' ws*)? identifier (node-space node-props-and-args)* node-space* (node-terminator | node-children)` /// `node := ('/-' ws*)? identifier (node-space node-props-and-args)* (node-space* node-children ws*)? node-terminator`
pub(crate) fn node(input: &str) -> IResult<&str, Option<KdlNode>, KdlParseError<&str>> { pub(crate) fn node(input: &str) -> IResult<&str, Option<KdlNode>, KdlParseError<&str>> {
let (input, comment) = opt(terminated(tag("/-"), many0(whitespace)))(input)?; let (input, comment) = opt(terminated(tag("/-"), many0(whitespace)))(input)?;
let (input, tag) = identifier(input)?; let (input, tag) = identifier(input)?;
let (input, args) = many0(preceded(node_space, node_prop_or_arg))(input)?; let (input, args) = many0(preceded(node_space, node_prop_or_arg))(input)?;
let (input, _) = many0(node_space)(input)?; let (input, children) = opt(delimited(many0(node_space), node_children, many0(whitespace)))(input)?;
let (input, children) = alt((value(Vec::new(), node_terminator), node_children))(input)?; let (input, _) = node_terminator(input)?;
if comment.is_some() { if comment.is_some() {
Ok((input, None)) Ok((input, None))
} else { } else {
@ -86,7 +86,7 @@ pub(crate) fn node(input: &str) -> IResult<&str, Option<KdlNode>, KdlParseError<
input, input,
Some(KdlNode { Some(KdlNode {
name: tag, name: tag,
children, children: children.unwrap_or_else(Vec::new),
values: values values: values
.into_iter() .into_iter()
.map(|arg| match arg { .map(|arg| match arg {