adjusted list syntax to be [<content> ...] to create a visual difference from tuples, which don't have the ... before the ].

This commit is contained in:
Dummi26 2023-03-12 12:43:21 +01:00
parent ff1f487a6f
commit 369b37371c
2 changed files with 29 additions and 17 deletions

View File

@ -123,11 +123,14 @@ fn parse_statement_adv(
file.skip_whitespaces();
if let Some(']') = file.peek() {
file.next();
if file[file.get_char_index()..].starts_with("[]") {
break;
}
if file[file.get_char_index()..].starts_with("...]") {
list = true;
file.next();
file.next();
}
file.next();
file.next();
break;
}
v.push(parse_statement(file)?);
@ -314,6 +317,8 @@ fn parse_statement_adv(
}
};
file.skip_whitespaces();
if !file[file.get_char_index()..].starts_with("..") {
// dot chain syntax only works if there is only one dot
if let Some('.') = file.get_char(file.get_char_index()) {
// consume the dot (otherwise, a.b.c syntax will break in certain cases)
file.next();
@ -326,7 +331,10 @@ fn parse_statement_adv(
let args = [out].into_iter().chain(args.into_iter()).collect();
SStatementEnum::FunctionCall(func, args).into()
}
other => todo!("Wrapping in this type isn't implemented (yet?). Type: {other:?}"),
other => {
todo!("Wrapping in this type isn't implemented (yet?). Type: {other:?}")
}
}
}
}
}

View File

@ -832,6 +832,10 @@ impl Display for VDataEnum {
for v in v {
write!(f, "{v}")?;
}
match self {
Self::List(..) => write!(f, "...")?,
_ => (),
}
write!(f, "]")?;
Ok(())
}