updated site + added docs/builtins.md + statements can end with ',' to differentiate '1, -2' from '1 - 2' == '-1'.

This commit is contained in:
mark
2023-05-25 00:22:03 +02:00
parent 46653666f0
commit e766e78e96
8 changed files with 203 additions and 33 deletions

View File

@@ -1603,7 +1603,7 @@ impl BuiltinFunction {
let left = if left >= 0 {
left as usize
} else {
(a.len() - 1).saturating_sub(left.abs() as _)
a.len().saturating_sub(left.abs() as _)
};
if let Some(len) = len {
if len >= 0 {

View File

@@ -280,7 +280,8 @@ impl FormatGs for SStatement {
write!(f, " -> ")?;
force_opt.fmtgs(f, info, form, file)?;
}
self.statement.fmtgs(f, info, form, file)
self.statement.fmtgs(f, info, form, file)?;
write!(f, ",")
}
}
impl Display for SStatement {

View File

@@ -583,7 +583,7 @@ pub mod implementation {
let mut start = String::new();
loop {
fn is_delimeter(ch: char) -> bool {
matches!(ch, '}' | ']' | ')' | '.')
matches!(ch, '}' | ']' | ')' | '.' | ',')
}
let nchar = match file.peek() {
Some(ch) if is_delimeter(ch) => Some(ch),
@@ -596,16 +596,18 @@ pub mod implementation {
parse_statement(file)?,
)));
}
Some(ch)
if (ch.is_whitespace() || is_delimeter(ch)) && start.trim().is_empty() =>
{
return Err(ParseError {
err: ParseErrors::StatementCannotStartWith(ch),
location: *file.get_pos(),
location_end: None,
context: vec![],
info: None,
});
}
Some(ch) if ch.is_whitespace() || is_delimeter(ch) => {
if start.trim().is_empty() {
return Err(ParseError {
err: ParseErrors::StatementCannotStartWith(ch),
location: *file.get_pos(),
location_end: None,
context: vec![],
info: None,
});
}
file.skip_whitespaces();
// parse normal statement
let start = start.trim();
@@ -853,6 +855,10 @@ pub mod implementation {
// 080 .
// most local (evaluated first)
out = match (chain_level, file.peek()) {
(_, Some(',')) => {
file.next();
break;
}
// 080 .
(0..=80, Some('.'))
if !matches!(