forked from extern/nushell
cleanup
This commit is contained in:
parent
0a6f62bc0e
commit
9916f35b22
@ -43,7 +43,7 @@ pub enum SyntaxShape {
|
|||||||
/// A block is allowed, eg `{start this thing}`
|
/// A block is allowed, eg `{start this thing}`
|
||||||
Block,
|
Block,
|
||||||
|
|
||||||
/// A table is allowed, eg `[first second]`
|
/// A table is allowed, eg `[[first, second]; [1, 2]]`
|
||||||
Table,
|
Table,
|
||||||
|
|
||||||
/// A table is allowed, eg `[first second]`
|
/// A table is allowed, eg `[first second]`
|
||||||
@ -519,6 +519,7 @@ impl ParserWorkingSet {
|
|||||||
while spans_idx < spans.len() {
|
while spans_idx < spans.len() {
|
||||||
let arg_span = spans[spans_idx];
|
let arg_span = spans[spans_idx];
|
||||||
|
|
||||||
|
// Check if we're on a long flag, if so, parse
|
||||||
let (long_name, arg, err) = self.parse_long_flag(spans, &mut spans_idx, &sig);
|
let (long_name, arg, err) = self.parse_long_flag(spans, &mut spans_idx, &sig);
|
||||||
if let Some(long_name) = long_name {
|
if let Some(long_name) = long_name {
|
||||||
// We found a long flag, like --bar
|
// We found a long flag, like --bar
|
||||||
@ -528,6 +529,7 @@ impl ParserWorkingSet {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we're on a short flag or group of short flags, if so, parse
|
||||||
let (short_flags, err) =
|
let (short_flags, err) =
|
||||||
self.parse_short_flags(spans, &mut spans_idx, positional_idx, &sig);
|
self.parse_short_flags(spans, &mut spans_idx, positional_idx, &sig);
|
||||||
|
|
||||||
@ -552,6 +554,7 @@ impl ParserWorkingSet {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse a positional arg if there is one
|
||||||
if let Some(positional) = sig.get_positional(positional_idx) {
|
if let Some(positional) = sig.get_positional(positional_idx) {
|
||||||
//Make sure we leave enough spans for the remaining positionals
|
//Make sure we leave enough spans for the remaining positionals
|
||||||
let remainder = sig.num_positionals() - positional_idx;
|
let remainder = sig.num_positionals() - positional_idx;
|
||||||
@ -1070,7 +1073,16 @@ impl ParserWorkingSet {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SyntaxShape::List(elem) => self.parse_list_expression(span, &elem),
|
SyntaxShape::List(elem) => {
|
||||||
|
if bytes.starts_with(b"[") {
|
||||||
|
self.parse_list_expression(span, &elem)
|
||||||
|
} else {
|
||||||
|
(
|
||||||
|
Expression::garbage(span),
|
||||||
|
Some(ParseError::Mismatch("list".into(), span)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
SyntaxShape::Table => {
|
SyntaxShape::Table => {
|
||||||
if bytes.starts_with(b"[") {
|
if bytes.starts_with(b"[") {
|
||||||
self.parse_table_expression(span)
|
self.parse_table_expression(span)
|
||||||
@ -1082,15 +1094,15 @@ impl ParserWorkingSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SyntaxShape::Any => {
|
SyntaxShape::Any => {
|
||||||
let shapes = vec![
|
let shapes = [
|
||||||
SyntaxShape::Int,
|
SyntaxShape::Int,
|
||||||
SyntaxShape::Number,
|
SyntaxShape::Number,
|
||||||
SyntaxShape::Range,
|
SyntaxShape::Range,
|
||||||
SyntaxShape::Filesize,
|
SyntaxShape::Filesize,
|
||||||
SyntaxShape::Duration,
|
SyntaxShape::Duration,
|
||||||
SyntaxShape::Block,
|
SyntaxShape::Block,
|
||||||
SyntaxShape::List(Box::new(SyntaxShape::Any)),
|
|
||||||
SyntaxShape::Table,
|
SyntaxShape::Table,
|
||||||
|
SyntaxShape::List(Box::new(SyntaxShape::Any)),
|
||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
];
|
];
|
||||||
for shape in shapes.iter() {
|
for shape in shapes.iter() {
|
||||||
|
Loading…
Reference in New Issue
Block a user