Remove warnings. Improve unknown flags

This commit is contained in:
JT 2021-07-02 10:54:04 +12:00
parent 7f3eab418f
commit c1240f214c
3 changed files with 10 additions and 6 deletions

View file

@ -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<()> {
if let Some(path) = std::env::args().nth(1) {

View file

@ -40,7 +40,7 @@ pub enum SyntaxShape {
/// 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
RowCondition,
/// A general math expression, eg the `1 + 2` of `= 1 + 2`
/// A general math expression, eg `1 + 2`
MathExpression,
}
@ -283,6 +283,10 @@ impl ParserWorkingSet {
} else if let Some(first) = unmatched_short_flags.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 {

View file

@ -1,5 +1,4 @@
use crate::{ParseError, Signature, Span};
use core::num;
use crate::{Signature, Span};
use std::{collections::HashMap, sync::Arc};
pub struct ParserState {
@ -79,6 +78,7 @@ impl ParserState {
self.decls.get(decl_id)
}
#[allow(unused)]
pub(crate) fn add_file(&mut self, filename: String, contents: Vec<u8>) -> usize {
self.files.push((filename, contents));
@ -258,11 +258,11 @@ mod parser_state_tests {
#[test]
fn merge_states() {
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 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);