diff --git a/.cargo/config b/.cargo/config index 6727dab68..e69de29bb 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1 +0,0 @@ -paths = ["C:\\Users\\wycat\\Code\\nom_locate"] \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 0db81d783..4ccd32ff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -473,7 +473,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -538,7 +538,7 @@ dependencies = [ "ident_case 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -551,7 +551,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -561,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -571,7 +571,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling_core 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -581,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -593,7 +593,7 @@ dependencies = [ "derive_builder_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -604,7 +604,7 @@ dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -617,7 +617,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -786,7 +786,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive_internals 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -820,7 +820,7 @@ dependencies = [ "darling 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -860,7 +860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1018,7 +1018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1360,7 +1360,7 @@ dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1535,7 +1535,7 @@ dependencies = [ [[package]] name = "nom" -version = "5.0.0-beta2" +version = "5.0.0-beta3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lexical-core 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1546,11 +1546,11 @@ dependencies = [ [[package]] name = "nom_locate" version = "0.3.1" -source = "git+https://github.com/wycats/nom_locate.git?branch=nom5#9383cc779b23a746ff68cc7094d9ed7baaa661b2" +source = "git+https://github.com/wycats/nom_locate.git?branch=nom5#b981e045fdaf29dbbf6e83803a01896cf280d862" dependencies = [ "bytecount 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.0-beta2 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.0-beta3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1589,7 +1589,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "logos 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", "logos-derive 0.10.0-rc2 (registry+https://github.com/rust-lang/crates.io-index)", - "nom 5.0.0-beta2 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 5.0.0-beta3 (registry+https://github.com/rust-lang/crates.io-index)", "nom_locate 0.3.1 (git+https://github.com/wycats/nom_locate.git?branch=nom5)", "ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "pancurses 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2472,7 +2472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2481,7 +2481,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2640,7 +2640,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.36" +version = "0.15.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2655,7 +2655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2973,7 +2973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "darling 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3401,7 +3401,7 @@ dependencies = [ "checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -"checksum nom 5.0.0-beta2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfa215de9f747c2b3290ceee185976eb6ffc936087e19d810b57ba3ff85ae28c" +"checksum nom 5.0.0-beta3 (registry+https://github.com/rust-lang/crates.io-index)" = "2a99b2ae5161172f34c0512d051644e1cc74558f4721c9964f39d354d9e5b408" "checksum nom_locate 0.3.1 (git+https://github.com/wycats/nom_locate.git?branch=nom5)" = "" "checksum num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf4825417e1e1406b3782a8ce92f4d53f26ec055e3622e1881ca8e9f5f9e08db" "checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc" @@ -3517,7 +3517,7 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum subprocess 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "28fc0f40f0c0da73339d347aa7d6d2b90341a95683a47722bc4eebed71ff3c00" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)" = "8b4f551a91e2e3848aeef8751d0d4eec9489b6474c720fd4c55958d8d31a430c" +"checksum syn 0.15.37 (registry+https://github.com/rust-lang/crates.io-index)" = "e11410033fd5cf69a1cf2084604e011190c56f11e08ffc53df880f5f65f1c6e4" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e80b8831c5a543192ffc3727f01cf0e57579c6ac15558e3048bfb5708892167b" "checksum sys-info 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "76d6cf7b349b6a6daaf7a3797227e2f4108c8dd398e0aca7e29b9fb239948541" diff --git a/src/commands/classified.rs b/src/commands/classified.rs index 65c5ed875..352c1ee63 100644 --- a/src/commands/classified.rs +++ b/src/commands/classified.rs @@ -1,6 +1,5 @@ use crate::commands::command::Sink; -use crate::parser::parse2::span::Spanned; -use crate::parser::{registry::Args, Span, TokenNode}; +use crate::parser::{registry::Args, Span, Spanned, TokenNode}; use crate::prelude::*; use bytes::{BufMut, BytesMut}; use futures::stream::StreamExt; @@ -195,7 +194,6 @@ impl ExternalCommand { let mut arg_string = format!("{}", self.name); for arg in &self.args { - //arg_string.push_str(" "); arg_string.push_str(&arg); } diff --git a/src/parser/hir.rs b/src/parser/hir.rs index 0b7e90cdc..7ab79a8d9 100644 --- a/src/parser/hir.rs +++ b/src/parser/hir.rs @@ -9,9 +9,7 @@ use derive_new::new; use getset::Getters; crate use baseline_parse::baseline_parse_single_token; -crate use baseline_parse_tokens::{ - baseline_parse_next_expr, ExpressionKindHint, -}; +crate use baseline_parse_tokens::{baseline_parse_next_expr, ExpressionKindHint}; crate use binary::Binary; crate use named::NamedArguments; crate use path::Path; diff --git a/src/parser/hir/baseline_parse.rs b/src/parser/hir/baseline_parse.rs index 1150434fc..ae9240cd4 100644 --- a/src/parser/hir/baseline_parse.rs +++ b/src/parser/hir/baseline_parse.rs @@ -1,20 +1,4 @@ -use crate::errors::ShellError; -use crate::parser::{hir, CommandRegistry, RawToken, Token, TokenNode}; - -// pub fn baseline_parse_token( -// token_node: TokenNode, -// _registry: &dyn CommandRegistry, -// ) -> Result { -// match token_node { -// TokenNode::Token(token) => Ok(baseline_parse_single_token(token)), -// TokenNode::Call(_call) => Err(ShellError::unimplemented("baseline_parse Call")), -// TokenNode::Delimited(_delimited) => { -// Err(ShellError::unimplemented("baseline_parse Delimited")) -// } -// TokenNode::Pipeline(_pipeline) => Err(ShellError::unimplemented("baseline_parse Pipeline")), -// TokenNode::Path(_path) => Err(ShellError::unimplemented("baseline_parse Path")), -// } -// } +use crate::parser::{hir, RawToken, Token}; pub fn baseline_parse_single_token(token: &Token, source: &str) -> hir::Expression { match *token.item() { diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index 4cf8ae86b..39c1fcaee 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -23,6 +23,7 @@ pub fn baseline_parse_tokens( Ok(exprs) } +#[allow(unused)] #[derive(Debug)] pub enum ExpressionKindHint { Literal, @@ -134,15 +135,15 @@ pub fn baseline_parse_semantic_token( ) -> Result { match token { TokenNode::Token(token) => Ok(baseline_parse_single_token(token, source)), - TokenNode::Call(call) => unimplemented!(), - TokenNode::Delimited(delimited) => unimplemented!(), - TokenNode::Pipeline(pipeline) => unimplemented!(), + TokenNode::Call(_call) => unimplemented!(), + TokenNode::Delimited(_delimited) => unimplemented!(), + TokenNode::Pipeline(_pipeline) => unimplemented!(), TokenNode::Operator(_op) => unreachable!(), - TokenNode::Flag(flag) => unimplemented!(), + TokenNode::Flag(_flag) => unimplemented!(), TokenNode::Identifier(_span) => unreachable!(), TokenNode::Whitespace(_span) => unreachable!(), TokenNode::Error(error) => Err(*error.item.clone()), - TokenNode::Path(path) => unimplemented!(), + TokenNode::Path(_path) => unimplemented!(), } } @@ -154,24 +155,3 @@ fn next_token(nodes: &mut impl Iterator) -> Option<&'a Tok } } } - -fn baseline_parse_token( - token_node: &TokenNode, - _registry: &dyn CommandRegistry, - source: &str, -) -> Result { - match token_node { - TokenNode::Token(token) => Ok(hir::baseline_parse_single_token(token, source)), - TokenNode::Call(_call) => Err(ShellError::unimplemented("baseline_parse Call")), - TokenNode::Delimited(_delimited) => { - Err(ShellError::unimplemented("baseline_parse Delimited")) - } - TokenNode::Pipeline(_pipeline) => Err(ShellError::unimplemented("baseline_parse Pipeline")), - TokenNode::Path(_path) => Err(ShellError::unimplemented("baseline_parse Path")), - TokenNode::Operator(_op) => Err(ShellError::unimplemented("baseline_parse Operator")), - TokenNode::Flag(_op) => Err(ShellError::unimplemented("baseline_parse Flag")), - TokenNode::Identifier(_op) => Err(ShellError::unimplemented("baseline_parse Identifier")), - TokenNode::Whitespace(_op) => Err(ShellError::unimplemented("baseline_parse Whitespace")), - TokenNode::Error(err) => Err(*err.item.clone()), - } -} diff --git a/src/parser/hir/path.rs b/src/parser/hir/path.rs index 132f3112b..02bf8e5ce 100644 --- a/src/parser/hir/path.rs +++ b/src/parser/hir/path.rs @@ -1,4 +1,4 @@ -use crate::parser::{hir::Expression, Operator, Spanned}; +use crate::parser::{hir::Expression, Spanned}; use derive_new::new; use getset::Getters; diff --git a/src/parser/parse2/parser.rs b/src/parser/parse2/parser.rs index e7cac1bc2..81d529364 100644 --- a/src/parser/parse2/parser.rs +++ b/src/parser/parse2/parser.rs @@ -244,7 +244,6 @@ pub fn size(input: NomSpan) -> IResult { pub fn leaf(input: NomSpan) -> IResult { trace_step(input, "leaf", move |input| { - println!("alt: {:?}", input); let (input, node) = alt((size, integer, string, operator, flag, shorthand, var, bare))(input)?; diff --git a/src/parser/parse2/span.rs b/src/parser/parse2/span.rs index 4214d29aa..928352d69 100644 --- a/src/parser/parse2/span.rs +++ b/src/parser/parse2/span.rs @@ -32,7 +32,7 @@ impl Spanned { } crate fn copy_span(&self, output: U) -> Spanned { - let Spanned { span, item } = self; + let Spanned { span, .. } = self; Spanned { span: *span, diff --git a/src/parser/parse2/token_tree.rs b/src/parser/parse2/token_tree.rs index 9718e9def..e618feaa9 100644 --- a/src/parser/parse2/token_tree.rs +++ b/src/parser/parse2/token_tree.rs @@ -44,13 +44,6 @@ impl TokenNode { self.span().slice(source) } - pub fn is_ws(&self) -> bool { - match self { - TokenNode::Whitespace(_) => true, - _ => false, - } - } - pub fn is_bare(&self) -> bool { match self { TokenNode::Token(Spanned { @@ -61,20 +54,6 @@ impl TokenNode { } } - crate fn as_string(&self, source: &str) -> Option> { - match self { - TokenNode::Token(Spanned { - item: RawToken::Bare, - span, - }) => Some(Spanned::from_item(span.slice(source).to_string(), span)), - TokenNode::Token(Spanned { - item: RawToken::String(inner), - span, - }) => Some(Spanned::from_item(inner.slice(source).to_string(), span)), - _ => None, - } - } - crate fn as_flag(&self, value: &str, source: &str) -> Option> { match self { TokenNode::Flag( diff --git a/src/shell/helper.rs b/src/shell/helper.rs index b09a11a7a..85ad50de6 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -55,7 +55,6 @@ impl Highlighter for Helper { } fn highlight<'l>(&self, line: &'l str, _pos: usize) -> Cow<'l, str> { - let tokens = crate::parser::pipeline(nom_input(line)); match tokens {