diff --git a/src/cli.rs b/src/cli.rs index 638bc3b957..7831e11564 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -51,7 +51,7 @@ pub async fn cli() -> Result<(), Box> { ("size", Arc::new(size::size)), ("from-json", Arc::new(from_json::from_json)), ("open", Arc::new(open::open)), - ("column", Arc::new(select::select)), + ("column", Arc::new(column::column)), ("split", Arc::new(split::split)), ("reject", Arc::new(reject::reject)), ("to-array", Arc::new(to_array::to_array)), diff --git a/src/commands.rs b/src/commands.rs index e444f38535..4aa0fbf80f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,13 +1,13 @@ crate mod args; crate mod cd; crate mod classified; +crate mod column; crate mod command; crate mod from_json; crate mod ls; crate mod open; crate mod ps; crate mod reject; -crate mod select; crate mod size; crate mod skip; crate mod sort_by; diff --git a/src/commands/select.rs b/src/commands/column.rs similarity index 89% rename from src/commands/select.rs rename to src/commands/column.rs index 3703c6217a..997f49a50a 100644 --- a/src/commands/select.rs +++ b/src/commands/column.rs @@ -3,7 +3,7 @@ use crate::object::base::select_fields; use crate::object::Value; use crate::prelude::*; -pub fn select(args: CommandArgs) -> Result { +pub fn column(args: CommandArgs) -> Result { if args.args.is_empty() { return Err(ShellError::string("select requires a field")); } diff --git a/src/object/base.rs b/src/object/base.rs index de7bb26e48..d4759d11f8 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -54,7 +54,7 @@ impl Primitive { return Color::Black.bold().paint("Empty".to_string()).to_string(); } - let byte = byte.get_appropriate_unit(true); + let byte = byte.get_appropriate_unit(false); match byte.get_unit() { byte_unit::ByteUnit::B => format!("{}", byte.format(0)), diff --git a/src/parser/parser.lalrpop b/src/parser/parser.lalrpop index 05a74c8eb8..5afef11c48 100644 --- a/src/parser/parser.lalrpop +++ b/src/parser/parser.lalrpop @@ -1,5 +1,6 @@ use std::str::FromStr; use crate::parser::tokens::*; +use byte_unit::Byte; grammar; @@ -42,6 +43,7 @@ String: String = { Leaf: Leaf = { => Leaf::String(<>), + => Leaf::Int(<>), => Leaf::Int(<>), => match <>.as_ref() { "true" => Leaf::Boolean(true), @@ -54,3 +56,4 @@ RawBareWord: String = => <>.to_string(); DQString: String = => s[1..s.len() - 1].to_string(); SQString: String = => s[1..s.len() - 1].to_string(); Num: i64 = => i64::from_str(s).unwrap(); +Size: i64 = => Byte::from_string(s).unwrap().get_bytes() as i64; diff --git a/src/parser/parser.rs b/src/parser/parser.rs index cec2c99950..dc60f909dd 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -1,7 +1,8 @@ // auto-generated: "lalrpop 0.17.0" -// sha256: 7132ca5588d13f92326a5d97d9b36dd552bef8de12f7ab694b98ba1b169c5 +// sha256: f99d6ffb543c2f4bf7dd50b8ef84cfc8bc946c3a5d6bccb5d5cffcb5de020da use std::str::FromStr; use crate::parser::tokens::*; +use byte_unit::Byte; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] @@ -13,6 +14,7 @@ mod __parse__Pipeline { use std::str::FromStr; use crate::parser::tokens::*; + use byte_unit::Byte; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] @@ -36,87 +38,91 @@ mod __parse__Pipeline { } const __ACTION: &'static [i8] = &[ // State 0 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, // State 1 - 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, // State 2 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 3 - 0, 0, 0, 0, 0, 0, 0, 0, -5, 17, 18, 19, 5, + 0, 0, 0, 0, 0, 0, 0, 0, -5, 18, 19, 20, 21, 5, // State 4 - -28, 0, 0, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, + -29, 0, 0, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, // State 5 - 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, // State 6 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, // State 7 - 0, 0, 0, 0, 0, 0, 0, 0, -9, -9, -9, -9, -9, + 0, 0, 0, 0, 0, 0, 0, 0, -9, -9, -9, -9, -9, -9, // State 8 - -31, 0, 0, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, + -33, 0, 0, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, // State 9 - 0, 0, 0, 0, 0, 0, 0, 0, -12, -12, -12, -12, -12, + 0, 0, 0, 0, 0, 0, 0, 0, -12, -12, -12, -12, -12, -12, // State 10 - 0, 0, 0, 0, 0, 0, 0, 0, -6, 17, 18, 19, 5, + 0, 0, 0, 0, 0, 0, 0, 0, -6, 18, 19, 20, 21, 5, // State 11 - 24, 0, 0, 25, 26, 27, 28, 29, -8, -8, -8, -8, -8, + 26, 0, 0, 27, 28, 29, 30, 31, -8, -8, -8, -8, -8, -8, // State 12 - -17, 0, 0, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, + -18, 0, 0, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, // State 13 - -18, 0, 0, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -19, 0, 0, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, // State 14 - -30, 0, 0, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, + -32, 0, 0, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, -32, // State 15 - -16, 0, 0, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, + -17, 0, 0, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, // State 16 - -7, 0, 0, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, + -16, 0, 0, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, // State 17 - -29, 0, 0, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, + -7, 0, 0, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, // State 18 - -19, 0, 0, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, + -30, 0, 0, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, // State 19 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + -20, 0, 0, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, // State 20 - 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, + -31, 0, 0, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, -31, // State 21 - 0, 0, 0, 0, 0, 0, 0, 0, -13, -13, -13, -13, -13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, // State 22 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 19, 5, + 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, // State 23 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, -21, -21, -21, + 0, 0, 0, 0, 0, 0, 0, 0, -13, -13, -13, -13, -13, -13, // State 24 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -22, -22, -22, -22, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 19, 20, 21, 5, // State 25 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -24, -24, -24, -24, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -22, -22, -22, -22, -22, // State 26 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -20, -20, -20, -20, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -23, -23, -23, -23, -23, // State 27 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -23, -23, -23, -23, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -25, -25, -25, -25, -25, // State 28 - 0, 0, 0, 0, 0, 0, 0, 0, 0, -25, -25, -25, -25, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -21, -21, -21, -21, -21, // State 29 - 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -24, -24, -24, -24, -24, // State 30 - 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, -4, -4, -4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -26, -26, -26, -26, -26, + // State 31 + 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, + // State 32 + 0, 0, 0, 0, 0, 0, 0, 0, -4, -4, -4, -4, -4, -4, ]; const __EOF_ACTION: &'static [i8] = &[ // State 0 0, // State 1 - -26, + -27, // State 2 - -32, + -34, // State 3 -5, // State 4 - -28, + -29, // State 5 - -27, + -28, // State 6 0, // State 7 -9, // State 8 - -31, + -33, // State 9 -12, // State 10 @@ -124,29 +130,29 @@ mod __parse__Pipeline { // State 11 -8, // State 12 - -17, - // State 13 -18, - // State 14 - -30, - // State 15 - -16, - // State 16 - -7, - // State 17 - -29, - // State 18 + // State 13 -19, + // State 14 + -32, + // State 15 + -17, + // State 16 + -16, + // State 17 + -7, + // State 18 + -30, // State 19 - 0, + -20, // State 20 - -2, + -31, // State 21 - -13, + 0, // State 22 - 0, + -2, // State 23 - 0, + -13, // State 24 0, // State 25 @@ -158,73 +164,81 @@ mod __parse__Pipeline { // State 28 0, // State 29 - -3, + 0, // State 30 + 0, + // State 31 + -3, + // State 32 -4, ]; const __GOTO: &'static [i8] = &[ // State 0 - 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, + 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 0, // State 1 - 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, // State 29 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // State 30 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + // State 31 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + // State 32 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]; fn __expected_tokens(__state: usize) -> Vec<::std::string::String> { const __TERMINAL: &'static [&'static str] = &[ @@ -240,9 +254,10 @@ mod __parse__Pipeline { r###"r#"\"([^\"]|\\\\\")*\""#"###, r###"r#"\'([^\']|\\\\\')*\'"#"###, r###"r#"-?[0-9]+"#"###, + r###"r#"-?[0-9]+[A-Za-z]+"#"###, r###"r#"[^0-9\"\'\\-][^\\s]*"#"###, ]; - __ACTION[(__state * 13)..].iter().zip(__TERMINAL).filter_map(|(&state, terminal)| { + __ACTION[(__state * 14)..].iter().zip(__TERMINAL).filter_map(|(&state, terminal)| { if state == 0 { None } else { @@ -287,12 +302,12 @@ mod __parse__Pipeline { #[inline] fn action(&self, state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 13 + integer] + __ACTION[(state as usize) * 14 + integer] } #[inline] fn error_action(&self, state: i8) -> i8 { - __ACTION[(state as usize) * 13 + (13 - 1)] + __ACTION[(state as usize) * 14 + (14 - 1)] } #[inline] @@ -302,7 +317,7 @@ mod __parse__Pipeline { #[inline] fn goto(&self, state: i8, nt: usize) -> i8 { - __GOTO[(state as usize) * 17 + nt] - 1 + __GOTO[(state as usize) * 18 + nt] - 1 } fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol { @@ -355,19 +370,20 @@ mod __parse__Pipeline { ) -> Option { match *__token { - Token(4, _) if true => Some(0), - Token(5, _) if true => Some(1), - Token(6, _) if true => Some(2), - Token(7, _) if true => Some(3), - Token(8, _) if true => Some(4), - Token(9, _) if true => Some(5), - Token(10, _) if true => Some(6), - Token(11, _) if true => Some(7), - Token(12, _) if true => Some(8), + Token(5, _) if true => Some(0), + Token(6, _) if true => Some(1), + Token(7, _) if true => Some(2), + Token(8, _) if true => Some(3), + Token(9, _) if true => Some(4), + Token(10, _) if true => Some(5), + Token(11, _) if true => Some(6), + Token(12, _) if true => Some(7), + Token(13, _) if true => Some(8), Token(0, _) if true => Some(9), Token(1, _) if true => Some(10), Token(2, _) if true => Some(11), Token(3, _) if true => Some(12), + Token(4, _) if true => Some(13), _ => None, } } @@ -381,41 +397,41 @@ mod __parse__Pipeline { { match __token_index { 0 => match __token { - Token(4, __tok0) => __Symbol::Variant0((__tok0)), - _ => unreachable!(), - }, - 1 => match __token { Token(5, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 2 => match __token { + 1 => match __token { Token(6, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 3 => match __token { + 2 => match __token { Token(7, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 4 => match __token { + 3 => match __token { Token(8, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 5 => match __token { + 4 => match __token { Token(9, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 6 => match __token { + 5 => match __token { Token(10, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 7 => match __token { + 6 => match __token { Token(11, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, - 8 => match __token { + 7 => match __token { Token(12, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, + 8 => match __token { + Token(13, __tok0) => __Symbol::Variant0((__tok0)), + _ => unreachable!(), + }, 9 => match __token { Token(0, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), @@ -432,6 +448,10 @@ mod __parse__Pipeline { Token(3, __tok0) => __Symbol::Variant0((__tok0)), _ => unreachable!(), }, + 13 => match __token { + Token(4, __tok0) => __Symbol::Variant0((__tok0)), + _ => unreachable!(), + }, _ => unreachable!(), } } @@ -554,13 +574,13 @@ mod __parse__Pipeline { 18 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 10, + nonterminal_produced: 9, } } 19 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 11, + nonterminal_produced: 10, } } 20 => { @@ -596,31 +616,31 @@ mod __parse__Pipeline { 25 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 12, + nonterminal_produced: 11, } } 26 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, + states_to_pop: 1, nonterminal_produced: 12, } } 27 => { __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 13, + states_to_pop: 2, + nonterminal_produced: 12, } } 28 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 14, + nonterminal_produced: 13, } } 29 => { __state_machine::SimulatedReduce::Reduce { states_to_pop: 1, - nonterminal_produced: 15, + nonterminal_produced: 14, } } 30 => { @@ -629,7 +649,19 @@ mod __parse__Pipeline { nonterminal_produced: 15, } } - 31 => __state_machine::SimulatedReduce::Accept, + 31 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + 32 => { + __state_machine::SimulatedReduce::Reduce { + states_to_pop: 1, + nonterminal_produced: 16, + } + } + 33 => __state_machine::SimulatedReduce::Accept, _ => panic!("invalid reduction index {}", __reduce_index) } } @@ -772,6 +804,12 @@ mod __parse__Pipeline { __reduce30(input, __action, __lookahead_start, __states, __symbols, ::std::marker::PhantomData::<(&())>) } 31 => { + __reduce31(input, __action, __lookahead_start, __states, __symbols, ::std::marker::PhantomData::<(&())>) + } + 32 => { + __reduce32(input, __action, __lookahead_start, __states, __symbols, ::std::marker::PhantomData::<(&())>) + } + 33 => { // __Pipeline = Pipeline => ActionFn(0); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); @@ -784,7 +822,7 @@ mod __parse__Pipeline { let __states_len = __states.len(); __states.truncate(__states_len - __pop_states); let __state = *__states.last().unwrap() as usize; - let __next_state = __GOTO[__state * 17 + __nonterminal] - 1; + let __next_state = __GOTO[__state * 18 + __nonterminal] - 1; __states.push(__next_state); None } @@ -931,12 +969,12 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // ("|" ) = "|", Command => ActionFn(28); + // ("|" ) = "|", Command => ActionFn(30); let __sym1 = __pop_Variant1(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action28::<>(input, __sym0, __sym1); + let __nt = super::__action30::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (2, 0) } @@ -951,12 +989,12 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // ("|" )+ = "|", Command => ActionFn(31); + // ("|" )+ = "|", Command => ActionFn(33); let __sym1 = __pop_Variant1(__symbols); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action31::<>(input, __sym0, __sym1); + let __nt = super::__action33::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (2, 1) } @@ -971,13 +1009,13 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // ("|" )+ = ("|" )+, "|", Command => ActionFn(32); + // ("|" )+ = ("|" )+, "|", Command => ActionFn(34); let __sym2 = __pop_Variant1(__symbols); let __sym1 = __pop_Variant0(__symbols); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym2.2.clone(); - let __nt = super::__action32::<>(input, __sym0, __sym1, __sym2); + let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant2(__nt), __end)); (3, 1) } @@ -1013,11 +1051,11 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Command = RawBareWord => ActionFn(33); + // Command = RawBareWord => ActionFn(35); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action33::<>(input, __sym0); + let __nt = super::__action35::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (1, 3) } @@ -1032,12 +1070,12 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Command = RawBareWord, Expr+ => ActionFn(34); + // Command = RawBareWord, Expr+ => ActionFn(36); let __sym1 = __pop_Variant6(__symbols); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action34::<>(input, __sym0, __sym1); + let __nt = super::__action36::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant1(__nt), __end)); (2, 3) } @@ -1052,11 +1090,11 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // DQString = r#"\"([^\"]|\\\\\")*\""# => ActionFn(21); + // DQString = r#"\"([^\"]|\\\\\")*\""# => ActionFn(22); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action21::<>(input, __sym0); + let __nt = super::__action22::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 4) } @@ -1109,10 +1147,10 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Expr* = => ActionFn(24); + // Expr* = => ActionFn(26); let __start = __symbols.last().map(|s| s.2.clone()).unwrap_or_default(); let __end = __lookahead_start.cloned().unwrap_or_else(|| __start.clone()); - let __nt = super::__action24::<>(input, &__start, &__end); + let __nt = super::__action26::<>(input, &__start, &__end); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (0, 6) } @@ -1127,11 +1165,11 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Expr* = Expr+ => ActionFn(25); + // Expr* = Expr+ => ActionFn(27); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action25::<>(input, __sym0); + let __nt = super::__action27::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 6) } @@ -1146,11 +1184,11 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Expr+ = Expr => ActionFn(29); + // Expr+ = Expr => ActionFn(31); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action29::<>(input, __sym0); + let __nt = super::__action31::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 7) } @@ -1165,12 +1203,12 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Expr+ = Expr+, Expr => ActionFn(30); + // Expr+ = Expr+, Expr => ActionFn(32); let __sym1 = __pop_Variant5(__symbols); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action30::<>(input, __sym0, __sym1); + let __nt = super::__action32::<>(input, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (2, 7) } @@ -1244,7 +1282,7 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Leaf = Num => ActionFn(18); + // Leaf = Size => ActionFn(18); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); @@ -1263,8 +1301,8 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Leaf = RawBareWord => ActionFn(19); - let __sym0 = __pop_Variant4(__symbols); + // Leaf = Num => ActionFn(19); + let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); let __nt = super::__action19::<>(input, __sym0); @@ -1282,15 +1320,34 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // Num = r#"-?[0-9]+"# => ActionFn(23); + // Leaf = RawBareWord => ActionFn(20); + let __sym0 = __pop_Variant4(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action20::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant8(__nt), __end)); + (1, 9) + } + pub(crate) fn __reduce19< + 'input, + >( + input: &'input str, + __action: i8, + __lookahead_start: Option<&usize>, + __states: &mut ::std::vec::Vec, + __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, + _: ::std::marker::PhantomData<(&'input ())>, + ) -> (usize, usize) + { + // Num = r#"-?[0-9]+"# => ActionFn(24); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action23::<>(input, __sym0); + let __nt = super::__action24::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 10) } - pub(crate) fn __reduce19< + pub(crate) fn __reduce20< 'input, >( input: &'input str, @@ -1309,7 +1366,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce20< + pub(crate) fn __reduce21< 'input, >( input: &'input str, @@ -1328,7 +1385,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce21< + pub(crate) fn __reduce22< 'input, >( input: &'input str, @@ -1347,7 +1404,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce22< + pub(crate) fn __reduce23< 'input, >( input: &'input str, @@ -1366,7 +1423,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce23< + pub(crate) fn __reduce24< 'input, >( input: &'input str, @@ -1385,7 +1442,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce24< + pub(crate) fn __reduce25< 'input, >( input: &'input str, @@ -1404,7 +1461,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (1, 11) } - pub(crate) fn __reduce25< + pub(crate) fn __reduce26< 'input, >( input: &'input str, @@ -1423,7 +1480,7 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 12) } - pub(crate) fn __reduce26< + pub(crate) fn __reduce27< 'input, >( input: &'input str, @@ -1443,25 +1500,6 @@ mod __parse__Pipeline { __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (2, 12) } - pub(crate) fn __reduce27< - 'input, - >( - input: &'input str, - __action: i8, - __lookahead_start: Option<&usize>, - __states: &mut ::std::vec::Vec, - __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: ::std::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // RawBareWord = r#"[^0-9\"\'\\-][^\\s]*"# => ActionFn(20); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action20::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (1, 13) - } pub(crate) fn __reduce28< 'input, >( @@ -1473,15 +1511,53 @@ mod __parse__Pipeline { _: ::std::marker::PhantomData<(&'input ())>, ) -> (usize, usize) { - // SQString = r#"\'([^\']|\\\\\')*\'"# => ActionFn(22); + // RawBareWord = r#"[^0-9\"\'\\-][^\\s]*"# => ActionFn(21); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action22::<>(input, __sym0); + let __nt = super::__action21::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant4(__nt), __end)); + (1, 13) + } + pub(crate) fn __reduce29< + 'input, + >( + input: &'input str, + __action: i8, + __lookahead_start: Option<&usize>, + __states: &mut ::std::vec::Vec, + __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, + _: ::std::marker::PhantomData<(&'input ())>, + ) -> (usize, usize) + { + // SQString = r#"\'([^\']|\\\\\')*\'"# => ActionFn(23); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action23::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); (1, 14) } - pub(crate) fn __reduce29< + pub(crate) fn __reduce30< + 'input, + >( + input: &'input str, + __action: i8, + __lookahead_start: Option<&usize>, + __states: &mut ::std::vec::Vec, + __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>, + _: ::std::marker::PhantomData<(&'input ())>, + ) -> (usize, usize) + { + // Size = r#"-?[0-9]+[A-Za-z]+"# => ActionFn(25); + let __sym0 = __pop_Variant0(__symbols); + let __start = __sym0.0.clone(); + let __end = __sym0.2.clone(); + let __nt = super::__action25::<>(input, __sym0); + __symbols.push((__start, __Symbol::Variant9(__nt), __end)); + (1, 15) + } + pub(crate) fn __reduce31< 'input, >( input: &'input str, @@ -1498,9 +1574,9 @@ mod __parse__Pipeline { let __end = __sym0.2.clone(); let __nt = super::__action15::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (1, 15) + (1, 16) } - pub(crate) fn __reduce30< + pub(crate) fn __reduce32< 'input, >( input: &'input str, @@ -1517,7 +1593,7 @@ mod __parse__Pipeline { let __end = __sym0.2.clone(); let __nt = super::__action16::<>(input, __sym0); __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (1, 15) + (1, 16) } } pub use self::__parse__Pipeline::PipelineParser; @@ -1526,6 +1602,7 @@ mod __intern_token { #![allow(unused_imports)] use std::str::FromStr; use crate::parser::tokens::*; + use byte_unit::Byte; #[allow(unused_extern_crates)] extern crate lalrpop_util as __lalrpop_util; #[allow(unused_imports)] @@ -1552,6 +1629,7 @@ mod __intern_token { "^(\"([\u{0}-!\\#-\u{10ffff}]|\\\\\")*\")", "^(\'([\u{0}-\\&\\(-\u{10ffff}]|\\\\\')*\')", "^(\\-?[0-9]+)", + "^(\\-?[0-9]+[A-Za-z]+)", "^([\u{0}-!\\#-\\&\\(-,\\.-/:-\u{10ffff}][\u{0}-\u{8}\u{e}-\u{1f}!-\u{84}\u{86}-\u{9f}¡-ᙿᚁ-\u{1fff}\u{200b}-‧\u{202a}-\u{202e}‰-⁞\u{2060}-\u{2fff}、-\u{10ffff}]*)", "^(!=)", "^(\\-)", @@ -1568,6 +1646,7 @@ mod __intern_token { __regex::Regex::new("^(\"([\u{0}-!\\#-\u{10ffff}]|\\\\\")*\")").unwrap(), __regex::Regex::new("^(\'([\u{0}-\\&\\(-\u{10ffff}]|\\\\\')*\')").unwrap(), __regex::Regex::new("^(\\-?[0-9]+)").unwrap(), + __regex::Regex::new("^(\\-?[0-9]+[A-Za-z]+)").unwrap(), __regex::Regex::new("^([\u{0}-!\\#-\\&\\(-,\\.-/:-\u{10ffff}][\u{0}-\u{8}\u{e}-\u{1f}!-\u{84}\u{86}-\u{9f}¡-ᙿᚁ-\u{1fff}\u{200b}-‧\u{202a}-\u{202e}‰-⁞\u{2060}-\u{2fff}、-\u{10ffff}]*)").unwrap(), __regex::Regex::new("^(!=)").unwrap(), __regex::Regex::new("^(\\-)").unwrap(), @@ -1618,7 +1697,7 @@ mod __intern_token { } else { let mut __longest_match = 0; let mut __index = 0; - for __i in 0 .. 13 { + for __i in 0 .. 14 { if __matches.matched(__i) { let __match = self.regex_vec[__i].find(__text).unwrap(); let __len = __match.end(); @@ -1859,6 +1938,17 @@ fn __action18< #[allow(unused_variables)] fn __action19< 'input, +>( + input: &'input str, + (_, __0, _): (usize, i64, usize), +) -> Leaf +{ + Leaf::Int(__0) +} + +#[allow(unused_variables)] +fn __action20< + 'input, >( input: &'input str, (_, __0, _): (usize, String, usize), @@ -1871,17 +1961,6 @@ fn __action19< } } -#[allow(unused_variables)] -fn __action20< - 'input, ->( - input: &'input str, - (_, s, _): (usize, &'input str, usize), -) -> String -{ - s.to_string() -} - #[allow(unused_variables)] fn __action21< 'input, @@ -1890,7 +1969,7 @@ fn __action21< (_, s, _): (usize, &'input str, usize), ) -> String { - s[1..s.len() - 1].to_string() + s.to_string() } #[allow(unused_variables)] @@ -1910,13 +1989,35 @@ fn __action23< >( input: &'input str, (_, s, _): (usize, &'input str, usize), +) -> String +{ + s[1..s.len() - 1].to_string() +} + +#[allow(unused_variables)] +fn __action24< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), ) -> i64 { i64::from_str(s).unwrap() } #[allow(unused_variables)] -fn __action24< +fn __action25< + 'input, +>( + input: &'input str, + (_, s, _): (usize, &'input str, usize), +) -> i64 +{ + Byte::from_string(s).unwrap().get_bytes() as i64 +} + +#[allow(unused_variables)] +fn __action26< 'input, >( input: &'input str, @@ -1928,7 +2029,7 @@ fn __action24< } #[allow(unused_variables)] -fn __action25< +fn __action27< 'input, >( input: &'input str, @@ -1939,7 +2040,7 @@ fn __action25< } #[allow(unused_variables)] -fn __action26< +fn __action28< 'input, >( input: &'input str, @@ -1950,7 +2051,7 @@ fn __action26< } #[allow(unused_variables)] -fn __action27< +fn __action29< 'input, >( input: &'input str, @@ -1962,7 +2063,7 @@ fn __action27< } #[allow(unused_variables)] -fn __action28< +fn __action30< 'input, >( input: &'input str, @@ -1974,7 +2075,7 @@ fn __action28< } #[allow(unused_variables)] -fn __action29< +fn __action31< 'input, >( input: &'input str, @@ -1985,7 +2086,7 @@ fn __action29< } #[allow(unused_variables)] -fn __action30< +fn __action32< 'input, >( input: &'input str, @@ -1997,7 +2098,7 @@ fn __action30< } #[allow(unused_variables)] -fn __action31< +fn __action33< 'input, >( input: &'input str, @@ -2007,20 +2108,20 @@ fn __action31< { let __start0 = __0.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action28( + let __temp0 = __action30( input, __0, __1, ); let __temp0 = (__start0, __temp0, __end0); - __action26( + __action28( input, __temp0, ) } #[allow(unused_variables)] -fn __action32< +fn __action34< 'input, >( input: &'input str, @@ -2031,13 +2132,13 @@ fn __action32< { let __start0 = __1.0.clone(); let __end0 = __2.2.clone(); - let __temp0 = __action28( + let __temp0 = __action30( input, __1, __2, ); let __temp0 = (__start0, __temp0, __end0); - __action27( + __action29( input, __0, __temp0, @@ -2045,7 +2146,7 @@ fn __action32< } #[allow(unused_variables)] -fn __action33< +fn __action35< 'input, >( input: &'input str, @@ -2054,7 +2155,7 @@ fn __action33< { let __start0 = __0.2.clone(); let __end0 = __0.2.clone(); - let __temp0 = __action24( + let __temp0 = __action26( input, &__start0, &__end0, @@ -2068,7 +2169,7 @@ fn __action33< } #[allow(unused_variables)] -fn __action34< +fn __action36< 'input, >( input: &'input str, @@ -2078,7 +2179,7 @@ fn __action34< { let __start0 = __1.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action25( + let __temp0 = __action27( input, __1, );