mirror of
https://github.com/nushell/nushell
synced 2025-01-28 21:05:48 +00:00
proper list/table guards
This commit is contained in:
parent
bc974a3e7d
commit
0a6f62bc0e
1 changed files with 18 additions and 4 deletions
|
@ -824,15 +824,18 @@ impl ParserWorkingSet {
|
||||||
let (output, err) = lite_parse(&output);
|
let (output, err) = lite_parse(&output);
|
||||||
error = error.or(err);
|
error = error.or(err);
|
||||||
|
|
||||||
println!("{:?}", output);
|
|
||||||
|
|
||||||
let mut args = vec![];
|
let mut args = vec![];
|
||||||
for arg in &output.block[0].commands {
|
for arg in &output.block[0].commands {
|
||||||
for part in &arg.parts {
|
let mut spans_idx = 0;
|
||||||
let (arg, err) = self.parse_value(*part, element_shape.clone());
|
|
||||||
|
while spans_idx < arg.parts.len() {
|
||||||
|
let (arg, err) =
|
||||||
|
self.parse_multispan_value(&arg.parts, &mut spans_idx, element_shape.clone());
|
||||||
error = error.or(err);
|
error = error.or(err);
|
||||||
|
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
|
|
||||||
|
spans_idx += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,6 +1005,16 @@ impl ParserWorkingSet {
|
||||||
return self.parse_dollar_expr(span);
|
return self.parse_dollar_expr(span);
|
||||||
} else if bytes.starts_with(b"(") {
|
} else if bytes.starts_with(b"(") {
|
||||||
return self.parse_full_column_path(span);
|
return self.parse_full_column_path(span);
|
||||||
|
} else if bytes.starts_with(b"[") {
|
||||||
|
match shape {
|
||||||
|
SyntaxShape::Any | SyntaxShape::List(_) | SyntaxShape::Table => {}
|
||||||
|
_ => {
|
||||||
|
return (
|
||||||
|
Expression::garbage(span),
|
||||||
|
Some(ParseError::Mismatch("non-table/non-list".into(), span)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match shape {
|
match shape {
|
||||||
|
@ -1076,6 +1089,7 @@ impl ParserWorkingSet {
|
||||||
SyntaxShape::Filesize,
|
SyntaxShape::Filesize,
|
||||||
SyntaxShape::Duration,
|
SyntaxShape::Duration,
|
||||||
SyntaxShape::Block,
|
SyntaxShape::Block,
|
||||||
|
SyntaxShape::List(Box::new(SyntaxShape::Any)),
|
||||||
SyntaxShape::Table,
|
SyntaxShape::Table,
|
||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue