forked from extern/nushell
Math operators (#1601)
* Add some math operations * WIP for adding compound expressions * precedence parsing * paren expressions * better lhs handling * add compound comparisons and shorthand lefthand parsing * Add or comparison and shorthand paths
This commit is contained in:
@ -78,6 +78,12 @@ fn bare(src: &mut Input, span_offset: usize) -> Result<Spanned<String>, ParseErr
|
||||
if let Some('{') = block_level.last() {
|
||||
let _ = block_level.pop();
|
||||
}
|
||||
} else if c == '(' {
|
||||
block_level.push(c);
|
||||
} else if c == ')' {
|
||||
if let Some('(') = block_level.last() {
|
||||
let _ = block_level.pop();
|
||||
}
|
||||
} else if block_level.is_empty() && c.is_whitespace() {
|
||||
break;
|
||||
}
|
||||
@ -162,9 +168,21 @@ fn pipeline(src: &mut Input, span_offset: usize) -> Result<LitePipeline, ParseEr
|
||||
// The first character tells us a lot about each argument
|
||||
match c {
|
||||
'|' => {
|
||||
// this is the end of this command
|
||||
let _ = src.next();
|
||||
break;
|
||||
if let Some((pos, next_c)) = src.peek() {
|
||||
if *next_c == '|' {
|
||||
// this isn't actually a pipeline but a comparison
|
||||
let span = Span::new(pos - 1 + span_offset, pos + 1 + span_offset);
|
||||
cmd.args.push("||".to_string().spanned(span));
|
||||
let _ = src.next();
|
||||
} else {
|
||||
// this is the end of this command
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// this is the end of this command
|
||||
break;
|
||||
}
|
||||
}
|
||||
'"' | '\'' => {
|
||||
let c = *c;
|
||||
|
Reference in New Issue
Block a user