mirror of
https://github.com/nushell/nushell
synced 2024-12-28 22:13:10 +00:00
Remove warnings. Improve unknown flags
This commit is contained in:
parent
7f3eab418f
commit
c1240f214c
3 changed files with 10 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
use engine_q::{lex, lite_parse, LexMode, ParserWorkingSet, Signature, SyntaxShape};
|
use engine_q::{ParserWorkingSet, Signature, SyntaxShape};
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
if let Some(path) = std::env::args().nth(1) {
|
if let Some(path) = std::env::args().nth(1) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub enum SyntaxShape {
|
||||||
/// A math expression which expands shorthand forms on the lefthand side, eg `foo > 1`
|
/// A math expression which expands shorthand forms on the lefthand side, eg `foo > 1`
|
||||||
/// The shorthand allows us to more easily reach columns inside of the row being passed in
|
/// The shorthand allows us to more easily reach columns inside of the row being passed in
|
||||||
RowCondition,
|
RowCondition,
|
||||||
/// A general math expression, eg the `1 + 2` of `= 1 + 2`
|
/// A general math expression, eg `1 + 2`
|
||||||
MathExpression,
|
MathExpression,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +283,10 @@ impl ParserWorkingSet {
|
||||||
} else if let Some(first) = unmatched_short_flags.first() {
|
} else if let Some(first) = unmatched_short_flags.first() {
|
||||||
error = error.or(Some(ParseError::UnknownFlag(*first)));
|
error = error.or(Some(ParseError::UnknownFlag(*first)));
|
||||||
}
|
}
|
||||||
|
} else if !unmatched_short_flags.is_empty() {
|
||||||
|
if let Some(first) = unmatched_short_flags.first() {
|
||||||
|
error = error.or(Some(ParseError::UnknownFlag(*first)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for flag in found_short_flags {
|
for flag in found_short_flags {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{ParseError, Signature, Span};
|
use crate::{Signature, Span};
|
||||||
use core::num;
|
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
pub struct ParserState {
|
pub struct ParserState {
|
||||||
|
@ -79,6 +78,7 @@ impl ParserState {
|
||||||
self.decls.get(decl_id)
|
self.decls.get(decl_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub(crate) fn add_file(&mut self, filename: String, contents: Vec<u8>) -> usize {
|
pub(crate) fn add_file(&mut self, filename: String, contents: Vec<u8>) -> usize {
|
||||||
self.files.push((filename, contents));
|
self.files.push((filename, contents));
|
||||||
|
|
||||||
|
@ -258,11 +258,11 @@ mod parser_state_tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn merge_states() {
|
fn merge_states() {
|
||||||
let mut parser_state = ParserState::new();
|
let mut parser_state = ParserState::new();
|
||||||
let parent_id = parser_state.add_file("test.nu".into(), vec![]);
|
parser_state.add_file("test.nu".into(), vec![]);
|
||||||
let mut parser_state = Arc::new(parser_state);
|
let mut parser_state = Arc::new(parser_state);
|
||||||
|
|
||||||
let mut working_set = ParserWorkingSet::new(Some(parser_state.clone()));
|
let mut working_set = ParserWorkingSet::new(Some(parser_state.clone()));
|
||||||
let working_set_id = working_set.add_file("child.nu".into(), vec![]);
|
working_set.add_file("child.nu".into(), vec![]);
|
||||||
|
|
||||||
ParserState::merge_working_set(&mut parser_state, working_set);
|
ParserState::merge_working_set(&mut parser_state, working_set);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue