diff --git a/Cargo.lock b/Cargo.lock index c0031297..9966a73a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,7 +13,7 @@ dependencies = [ [[package]] name = "air-parser" -version = "0.5.0" +version = "0.6.0" dependencies = [ "codespan", "codespan-reporting", @@ -22,6 +22,7 @@ dependencies = [ "itertools 0.10.0", "lalrpop", "lalrpop-util", + "multimap", "regex", "serde", "serde_json", @@ -1225,9 +1226,9 @@ checksum = "bba551d6d795f74a01767577ea8339560bf0a65354e0417b7e915ed608443d46" [[package]] name = "multimap" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" dependencies = [ "serde", ] diff --git a/crates/air-parser/Cargo.toml b/crates/air-parser/Cargo.toml index 0f86e6b0..d6de21a1 100644 --- a/crates/air-parser/Cargo.toml +++ b/crates/air-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "air-parser" -version = "0.5.0" +version = "0.6.0" authors = ["Fluence Labs"] edition = "2018" license = "Apache-2.0" @@ -13,6 +13,7 @@ lalrpop-util = "0.19.5" regex = "1.4.1" codespan = "0.9.5" codespan-reporting = "0.9.5" +multimap = "0.8.3" # TODO: hide serde behind a feature serde = { version = "=1.0.118", features = ["rc", "derive"] } diff --git a/crates/air-parser/src/parser/air.lalrpop b/crates/air-parser/src/parser/air.lalrpop index 0e206a70..699462d7 100644 --- a/crates/air-parser/src/parser/air.lalrpop +++ b/crates/air-parser/src/parser/air.lalrpop @@ -1,7 +1,9 @@ use crate::parser::ast::*; use crate::parser::air_parser::into_variable_and_path; use crate::parser::air_parser::make_flattened_error; -use crate::parser::lexer::LexerError; +use crate::parser::ParserError; +use crate::parser::VariableValidator; +use crate::parser::Span; use crate::parser::lexer::Token; use crate::parser::lexer::Number; @@ -9,27 +11,40 @@ use lalrpop_util::ErrorRecovery; use std::rc::Rc; // the only thing why input matters here is just introducing lifetime for Token -grammar<'err, 'input>(input: &'input str, errors: &'err mut Vec, LexerError>>); +grammar<'err, 'input, 'v>(input: &'input str, errors: &'err mut Vec, ParserError>>, validator: &'v mut VariableValidator<'input>); pub AIR = Instr; Instr: Box> = { - "(" call ")" => { + "(" call ")" => { let output = output.unwrap_or(CallOutputValue::None); let args = Rc::new(args); - Box::new(Instruction::Call(Call{peer_part: p, function_part: f, args, output})) + let call = Call { peer_part: p, function_part: f, args, output }; + let span = Span { left, right }; + validator.met_call(&call, span); + + Box::new(Instruction::Call(call)) }, "(" seq ")" => Box::new(Instruction::Seq(Seq(l, r))), "(" par ")" => Box::new(Instruction::Par(Par(l, r))), "(" null ")" => Box::new(Instruction::Null(Null)), - "(" fold ")" => { + "(" fold ")" => { let instruction = Rc::new(*i); - Box::new(Instruction::Fold(Fold{ iterable, iterator, instruction })) - }, - "(" next ")" => Box::new(Instruction::Next(Next(i))), + let fold = Fold { iterable, iterator, instruction }; + let span = Span { left, right }; + validator.met_fold(&fold, span); + Box::new(Instruction::Fold(fold)) + }, + "(" next ")" => { + let next = Next(i); + let span = Span { left, right }; + validator.met_next(&next, span); + + Box::new(Instruction::Next(next)) + }, "(" xor ")" => Box::new(Instruction::Xor(Xor(l, r))), @@ -104,6 +119,7 @@ Iterable: IterableValue<'input> = { => IterableValue::Variable(s), => { let (variable, path) = into_variable_and_path(v.0, v.1, v.2); + let should_flatten = v.2; IterableValue::JsonPath { variable, path, should_flatten } }, @@ -121,7 +137,7 @@ Matchable: MatchableValue<'input> = { extern { type Location = usize; - type Error = LexerError; + type Error = ParserError; enum Token<'input> { "(" => Token::OpenRoundBracket, diff --git a/crates/air-parser/src/parser/air.rs b/crates/air-parser/src/parser/air.rs index 98bfffdf..0558cd08 100644 --- a/crates/air-parser/src/parser/air.rs +++ b/crates/air-parser/src/parser/air.rs @@ -1,9 +1,11 @@ // auto-generated: "lalrpop 0.19.5" -// sha3: 13a01be9e7bfafe105fe6361390cdd12c867e4697238a32a5ba72af895616ee +// sha3: 9261142c295e3b691816383a436d7d9ae0591e6fd2e556966d1dfe61ccff84 use crate::parser::ast::*; use crate::parser::air_parser::into_variable_and_path; use crate::parser::air_parser::make_flattened_error; -use crate::parser::lexer::LexerError; +use crate::parser::ParserError; +use crate::parser::VariableValidator; +use crate::parser::Span; use crate::parser::lexer::Token; use crate::parser::lexer::Number; use lalrpop_util::ErrorRecovery; @@ -22,7 +24,9 @@ mod __parse__AIR { use crate::parser::ast::*; use crate::parser::air_parser::into_variable_and_path; use crate::parser::air_parser::make_flattened_error; - use crate::parser::lexer::LexerError; + use crate::parser::ParserError; + use crate::parser::VariableValidator; + use crate::parser::Span; use crate::parser::lexer::Token; use crate::parser::lexer::Number; use lalrpop_util::ErrorRecovery; @@ -42,7 +46,7 @@ mod __parse__AIR { Variant2(bool), Variant3((&'input str, usize, bool)), Variant4(Number), - Variant5(__lalrpop_util::ErrorRecovery, LexerError>), + Variant5(__lalrpop_util::ErrorRecovery, ParserError>), Variant6(CallInstrArgValue<'input>), Variant7(alloc::vec::Vec>), Variant8(usize), @@ -476,18 +480,19 @@ mod __parse__AIR { } }).collect() } - pub(crate) struct __StateMachine<'err, 'input> - where 'input: 'err + pub(crate) struct __StateMachine<'err, 'input, 'v> + where 'input: 'err, 'input: 'v { input: &'input str, - errors: &'err mut Vec, LexerError>>, - __phantom: core::marker::PhantomData<(&'err (), &'input ())>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __phantom: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, } - impl<'err, 'input> __state_machine::ParserDefinition for __StateMachine<'err, 'input> - where 'input: 'err + impl<'err, 'input, 'v> __state_machine::ParserDefinition for __StateMachine<'err, 'input, 'v> + where 'input: 'err, 'input: 'v { type Location = usize; - type Error = LexerError; + type Error = ParserError; type Token = Token<'input>; type TokenIndex = usize; type Symbol = __Symbol<'input>; @@ -509,7 +514,7 @@ mod __parse__AIR { #[inline] fn token_to_index(&self, token: &Self::Token) -> Option { - __token_to_integer(token, core::marker::PhantomData::<(&(), &())>) + __token_to_integer(token, core::marker::PhantomData::<(&(), &(), &())>) } #[inline] @@ -533,7 +538,7 @@ mod __parse__AIR { } fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol { - __token_to_symbol(token_index, token, core::marker::PhantomData::<(&(), &())>) + __token_to_symbol(token_index, token, core::marker::PhantomData::<(&(), &(), &())>) } fn expected_tokens(&self, state: i8) -> alloc::vec::Vec { @@ -563,24 +568,26 @@ mod __parse__AIR { __reduce( self.input, self.errors, + self.validator, action, start_location, states, symbols, - core::marker::PhantomData::<(&(), &())>, + core::marker::PhantomData::<(&(), &(), &())>, ) } fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce { - __simulate_reduce(action, core::marker::PhantomData::<(&(), &())>) + __simulate_reduce(action, core::marker::PhantomData::<(&(), &(), &())>) } } fn __token_to_integer< 'err, 'input, + 'v, >( __token: &Token<'input>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> Option { match *__token { @@ -611,10 +618,11 @@ mod __parse__AIR { fn __token_to_symbol< 'err, 'input, + 'v, >( __token_index: usize, __token: Token<'input>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> __Symbol<'input> { match __token_index { @@ -641,12 +649,14 @@ mod __parse__AIR { fn __simulate_reduce< 'err, 'input, + 'v, >( __reduce_index: i8, - _: core::marker::PhantomData<(&'err (), &'input ())>, - ) -> __state_machine::SimulatedReduce<__StateMachine<'err, 'input>> + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, + ) -> __state_machine::SimulatedReduce<__StateMachine<'err, 'input, 'v>> where 'input: 'err, + 'input: 'v, { match __reduce_index { 0 => { @@ -962,14 +972,16 @@ mod __parse__AIR { pub fn parse< 'err, 'input, - __TOKEN: __ToTriple<'err, 'input, >, + 'v, + __TOKEN: __ToTriple<'err, 'input, 'v, >, __TOKENS: IntoIterator, >( &self, input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __tokens0: __TOKENS, - ) -> Result>, __lalrpop_util::ParseError, LexerError>> + ) -> Result>, __lalrpop_util::ParseError, ParserError>> { let __tokens = __tokens0.into_iter(); let mut __tokens = __tokens.map(|t| __ToTriple::to_triple(t)); @@ -977,7 +989,8 @@ mod __parse__AIR { __StateMachine { input, errors, - __phantom: core::marker::PhantomData::<(&(), &())>, + validator, + __phantom: core::marker::PhantomData::<(&(), &(), &())>, }, __tokens, ) @@ -986,13 +999,15 @@ mod __parse__AIR { fn __accepts< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __error_state: i8, __states: & [i8], __opt_integer: Option, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> bool { let mut __states = __states.to_vec(); @@ -1006,7 +1021,7 @@ mod __parse__AIR { }; if __action == 0 { return false; } if __action > 0 { return true; } - let (__to_pop, __nt) = match __simulate_reduce(-(__action + 1), core::marker::PhantomData::<(&(), &())>) { + let (__to_pop, __nt) = match __simulate_reduce(-(__action + 1), core::marker::PhantomData::<(&(), &(), &())>) { __state_machine::SimulatedReduce::Reduce { states_to_pop, nonterminal_produced } => (states_to_pop, nonterminal_produced), @@ -1022,170 +1037,172 @@ mod __parse__AIR { pub(crate) fn __reduce< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __action: i8, __lookahead_start: Option<&usize>, __states: &mut alloc::vec::Vec, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, - ) -> Option>,__lalrpop_util::ParseError, LexerError>>> + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, + ) -> Option>,__lalrpop_util::ParseError, ParserError>>> { let (__pop_states, __nonterminal) = match __action { 0 => { - __reduce0(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce0(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 1 => { - __reduce1(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce1(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 2 => { - __reduce2(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce2(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 3 => { - __reduce3(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce3(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 4 => { - __reduce4(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce4(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 5 => { - __reduce5(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce5(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 6 => { - __reduce6(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce6(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 7 => { - __reduce7(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce7(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 8 => { - __reduce8(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce8(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 9 => { - __reduce9(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce9(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 10 => { - __reduce10(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce10(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 11 => { - __reduce11(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce11(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 12 => { - __reduce12(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce12(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 13 => { - __reduce13(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce13(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 14 => { - __reduce14(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce14(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 15 => { - __reduce15(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce15(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 16 => { - __reduce16(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce16(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 17 => { - __reduce17(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce17(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 18 => { - __reduce18(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce18(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 19 => { - __reduce19(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce19(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 20 => { - __reduce20(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce20(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 21 => { - __reduce21(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce21(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 22 => { - __reduce22(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce22(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 23 => { - __reduce23(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce23(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 24 => { - __reduce24(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce24(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 25 => { - __reduce25(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce25(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 26 => { - __reduce26(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce26(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 27 => { - __reduce27(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce27(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 28 => { - __reduce28(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce28(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 29 => { - __reduce29(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce29(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 30 => { - __reduce30(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce30(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 31 => { - __reduce31(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce31(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 32 => { - __reduce32(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce32(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 33 => { - __reduce33(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce33(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 34 => { - __reduce34(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce34(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 35 => { - __reduce35(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce35(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 36 => { - __reduce36(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce36(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 37 => { - __reduce37(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce37(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 38 => { - __reduce38(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce38(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 39 => { - __reduce39(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce39(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 40 => { - __reduce40(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce40(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 41 => { - __reduce41(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce41(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 42 => { - __reduce42(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce42(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 43 => { - __reduce43(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce43(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 44 => { - __reduce44(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce44(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 45 => { - __reduce45(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce45(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 46 => { - __reduce46(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce46(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 47 => { - __reduce47(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce47(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 48 => { - __reduce48(input, errors, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &())>) + __reduce48(input, errors, validator, __lookahead_start, __symbols, core::marker::PhantomData::<(&(), &(), &())>) } 49 => { // __AIR = AIR => ActionFn(0); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action0::<>(input, errors, __sym0); + let __nt = super::__action0::<>(input, errors, validator, __sym0); return Some(Ok(__nt)); } _ => panic!("invalid action code {}", __action) @@ -1337,7 +1354,7 @@ mod __parse__AIR { 'input, >( __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, __lalrpop_util::ErrorRecovery, LexerError>, usize) + ) -> (usize, __lalrpop_util::ErrorRecovery, ParserError>, usize) { match __symbols.pop() { Some((__l, __Symbol::Variant5(__v), __r)) => (__l, __v, __r), @@ -1402,87 +1419,97 @@ mod __parse__AIR { pub(crate) fn __reduce0< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // () = Arg => ActionFn(43); + // () = Arg => ActionFn(41); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action43::<>(input, errors, __sym0); + let __nt = super::__action41::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 0) } pub(crate) fn __reduce1< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // ()* = => ActionFn(41); + // ()* = => ActionFn(39); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action41::<>(input, errors, &__start, &__end); + let __nt = super::__action39::<>(input, errors, validator, &__start, &__end); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (0, 1) } pub(crate) fn __reduce2< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // ()* = ()+ => ActionFn(42); + // ()* = ()+ => ActionFn(40); let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action42::<>(input, errors, __sym0); + let __nt = super::__action40::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 1) } pub(crate) fn __reduce3< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // ()+ = Arg => ActionFn(48); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action48::<>(input, errors, __sym0); + let __nt = super::__action48::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (1, 2) } pub(crate) fn __reduce4< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // ()+ = ()+, Arg => ActionFn(49); @@ -1491,93 +1518,103 @@ mod __parse__AIR { let __sym0 = __pop_Variant7(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action49::<>(input, errors, __sym0, __sym1); + let __nt = super::__action49::<>(input, errors, validator, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant7(__nt), __end)); (2, 2) } pub(crate) fn __reduce5< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // @L = => ActionFn(40); + // @L = => ActionFn(45); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action40::<>(input, errors, &__start, &__end); + let __nt = super::__action45::<>(input, errors, validator, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 3) } pub(crate) fn __reduce6< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // @R = => ActionFn(39); + // @R = => ActionFn(42); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action39::<>(input, errors, &__start, &__end); + let __nt = super::__action42::<>(input, errors, validator, &__start, &__end); __symbols.push((__start, __Symbol::Variant8(__nt), __end)); (0, 4) } pub(crate) fn __reduce7< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // AIR = Instr => ActionFn(1); let __sym0 = __pop_Variant9(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action1::<>(input, errors, __sym0); + let __nt = super::__action1::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 5) } pub(crate) fn __reduce8< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Arg = CallInstrArgValue => ActionFn(26); let __sym0 = __pop_Variant6(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action26::<>(input, errors, __sym0); + let __nt = super::__action26::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 6) } pub(crate) fn __reduce9< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Args = "[", "]" => ActionFn(50); @@ -1586,19 +1623,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym1.2.clone(); - let __nt = super::__action50::<>(input, errors, __sym0, __sym1); + let __nt = super::__action50::<>(input, errors, validator, __sym0, __sym1); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (2, 7) } pub(crate) fn __reduce10< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Args = "[", ()+, "]" => ActionFn(51); @@ -1608,247 +1647,273 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym2.2.clone(); - let __nt = super::__action51::<>(input, errors, __sym0, __sym1, __sym2); + let __nt = super::__action51::<>(input, errors, validator, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant10(__nt), __end)); (3, 7) } pub(crate) fn __reduce11< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = Literal => ActionFn(27); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action27::<>(input, errors, __sym0); + let __nt = super::__action27::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce12< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = Alphanumeric => ActionFn(28); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(input, errors, __sym0); + let __nt = super::__action28::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce13< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = JsonPath => ActionFn(29); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action29::<>(input, errors, __sym0); + let __nt = super::__action29::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce14< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = Number => ActionFn(30); let __sym0 = __pop_Variant4(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action30::<>(input, errors, __sym0); + let __nt = super::__action30::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce15< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = Boolean => ActionFn(31); let __sym0 = __pop_Variant2(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action31::<>(input, errors, __sym0); + let __nt = super::__action31::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce16< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = InitPeerId => ActionFn(32); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action32::<>(input, errors, __sym0); + let __nt = super::__action32::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce17< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrArgValue = LastError => ActionFn(33); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action33::<>(input, errors, __sym0); + let __nt = super::__action33::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant6(__nt), __end)); (1, 8) } pub(crate) fn __reduce18< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrValue = Literal => ActionFn(22); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action22::<>(input, errors, __sym0); + let __nt = super::__action22::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 9) } pub(crate) fn __reduce19< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrValue = Alphanumeric => ActionFn(23); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action23::<>(input, errors, __sym0); + let __nt = super::__action23::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 9) } pub(crate) fn __reduce20< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // CallInstrValue = JsonPath => ActionFn(53); + // CallInstrValue = JsonPath => ActionFn(56); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action53::<>(input, errors, __sym0); + let __nt = super::__action56::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 9) } pub(crate) fn __reduce21< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // CallInstrValue = InitPeerId => ActionFn(25); let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action25::<>(input, errors, __sym0); + let __nt = super::__action25::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 9) } pub(crate) fn __reduce22< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // FPart = Function => ActionFn(13); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action13::<>(input, errors, __sym0); + let __nt = super::__action13::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (1, 10) } pub(crate) fn __reduce23< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // FPart = "(", ServiceId, Function, ")" => ActionFn(14); @@ -1859,41 +1924,45 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym3.2.clone(); - let __nt = super::__action14::<>(input, errors, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action14::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant12(__nt), __end)); (4, 10) } pub(crate) fn __reduce24< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Function = CallInstrValue => ActionFn(19); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action19::<>(input, errors, __sym0); + let __nt = super::__action19::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 11) } pub(crate) fn __reduce25< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Instr = "(", call, PeerPart, FPart, Args, Output, ")" => ActionFn(54); + // Instr = "(", call, PeerPart, FPart, Args, Output, ")" => ActionFn(60); assert!(__symbols.len() >= 7); let __sym6 = __pop_Variant0(__symbols); let __sym5 = __pop_Variant15(__symbols); @@ -1904,22 +1973,24 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym6.2.clone(); - let __nt = super::__action54::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); + let __nt = super::__action60::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (7, 12) } pub(crate) fn __reduce26< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Instr = "(", call, PeerPart, FPart, Args, ")" => ActionFn(55); + // Instr = "(", call, PeerPart, FPart, Args, ")" => ActionFn(61); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant10(__symbols); @@ -1929,19 +2000,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action55::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action61::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 12) } pub(crate) fn __reduce27< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", seq, Instr, Instr, ")" => ActionFn(3); @@ -1953,19 +2026,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); - let __nt = super::__action3::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action3::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (5, 12) } pub(crate) fn __reduce28< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", par, Instr, Instr, ")" => ActionFn(4); @@ -1977,19 +2052,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); - let __nt = super::__action4::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action4::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (5, 12) } pub(crate) fn __reduce29< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", null, ")" => ActionFn(5); @@ -1999,22 +2076,24 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym2.2.clone(); - let __nt = super::__action5::<>(input, errors, __sym0, __sym1, __sym2); + let __nt = super::__action5::<>(input, errors, validator, __sym0, __sym1, __sym2); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (3, 12) } pub(crate) fn __reduce30< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Instr = "(", fold, Iterable, Alphanumeric, Instr, ")" => ActionFn(6); + // Instr = "(", fold, Iterable, Alphanumeric, Instr, ")" => ActionFn(58); assert!(__symbols.len() >= 6); let __sym5 = __pop_Variant0(__symbols); let __sym4 = __pop_Variant9(__symbols); @@ -2024,22 +2103,24 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action6::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action58::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 12) } pub(crate) fn __reduce31< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Instr = "(", next, Alphanumeric, ")" => ActionFn(7); + // Instr = "(", next, Alphanumeric, ")" => ActionFn(59); assert!(__symbols.len() >= 4); let __sym3 = __pop_Variant0(__symbols); let __sym2 = __pop_Variant1(__symbols); @@ -2047,19 +2128,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym3.2.clone(); - let __nt = super::__action7::<>(input, errors, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action59::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (4, 12) } pub(crate) fn __reduce32< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", xor, Instr, Instr, ")" => ActionFn(8); @@ -2071,19 +2154,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym4.2.clone(); - let __nt = super::__action8::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4); + let __nt = super::__action8::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (5, 12) } pub(crate) fn __reduce33< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", match_, Matchable, Matchable, Instr, ")" => ActionFn(9); @@ -2096,19 +2181,21 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action9::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action9::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 12) } pub(crate) fn __reduce34< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = "(", mismatch, Matchable, Matchable, Instr, ")" => ActionFn(10); @@ -2121,246 +2208,272 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym5.2.clone(); - let __nt = super::__action10::<>(input, errors, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); + let __nt = super::__action10::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (6, 12) } pub(crate) fn __reduce35< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Instr = error => ActionFn(11); let __sym0 = __pop_Variant5(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action11::<>(input, errors, __sym0); + let __nt = super::__action11::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant9(__nt), __end)); (1, 12) } pub(crate) fn __reduce36< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Iterable = Alphanumeric => ActionFn(34); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action34::<>(input, errors, __sym0); + let __nt = super::__action34::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 13) } pub(crate) fn __reduce37< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Iterable = JsonPath => ActionFn(35); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action35::<>(input, errors, __sym0); + let __nt = super::__action35::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant13(__nt), __end)); (1, 13) } pub(crate) fn __reduce38< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Matchable = Alphanumeric => ActionFn(36); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action36::<>(input, errors, __sym0); + let __nt = super::__action36::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 14) } pub(crate) fn __reduce39< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Matchable = Literal => ActionFn(37); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action37::<>(input, errors, __sym0); + let __nt = super::__action37::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 14) } pub(crate) fn __reduce40< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Matchable = JsonPath => ActionFn(38); let __sym0 = __pop_Variant3(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action38::<>(input, errors, __sym0); + let __nt = super::__action38::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant14(__nt), __end)); (1, 14) } pub(crate) fn __reduce41< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Output = Alphanumeric => ActionFn(17); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action17::<>(input, errors, __sym0); + let __nt = super::__action17::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 15) } pub(crate) fn __reduce42< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // Output = Accumulator => ActionFn(18); let __sym0 = __pop_Variant1(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action18::<>(input, errors, __sym0); + let __nt = super::__action18::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant15(__nt), __end)); (1, 15) } pub(crate) fn __reduce43< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Output? = Output => ActionFn(44); + // Output? = Output => ActionFn(43); let __sym0 = __pop_Variant15(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action44::<>(input, errors, __sym0); + let __nt = super::__action43::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (1, 16) } pub(crate) fn __reduce44< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { - // Output? = => ActionFn(45); + // Output? = => ActionFn(44); let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2.clone())).unwrap_or_default(); let __end = __start.clone(); - let __nt = super::__action45::<>(input, errors, &__start, &__end); + let __nt = super::__action44::<>(input, errors, validator, &__start, &__end); __symbols.push((__start, __Symbol::Variant16(__nt), __end)); (0, 16) } pub(crate) fn __reduce45< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // PeerId = CallInstrValue => ActionFn(20); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action20::<>(input, errors, __sym0); + let __nt = super::__action20::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 17) } pub(crate) fn __reduce46< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // PeerPart = PeerId => ActionFn(15); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action15::<>(input, errors, __sym0); + let __nt = super::__action15::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (1, 18) } pub(crate) fn __reduce47< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // PeerPart = "(", PeerId, ServiceId, ")" => ActionFn(16); @@ -2371,26 +2484,28 @@ mod __parse__AIR { let __sym0 = __pop_Variant0(__symbols); let __start = __sym0.0.clone(); let __end = __sym3.2.clone(); - let __nt = super::__action16::<>(input, errors, __sym0, __sym1, __sym2, __sym3); + let __nt = super::__action16::<>(input, errors, validator, __sym0, __sym1, __sym2, __sym3); __symbols.push((__start, __Symbol::Variant17(__nt), __end)); (4, 18) } pub(crate) fn __reduce48< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookahead_start: Option<&usize>, __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'err (), &'input ())>, + _: core::marker::PhantomData<(&'err (), &'input (), &'v ())>, ) -> (usize, usize) { // ServiceId = CallInstrValue => ActionFn(21); let __sym0 = __pop_Variant11(__symbols); let __start = __sym0.0.clone(); let __end = __sym0.2.clone(); - let __nt = super::__action21::<>(input, errors, __sym0); + let __nt = super::__action21::<>(input, errors, validator, __sym0); __symbols.push((__start, __Symbol::Variant11(__nt), __end)); (1, 19) } @@ -2401,9 +2516,11 @@ pub use self::__parse__AIR::AIRParser; fn __action0< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Box>, usize), ) -> Box> { @@ -2414,9 +2531,11 @@ fn __action0< fn __action1< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Box>, usize), ) -> Box> { @@ -2427,9 +2546,12 @@ fn __action1< fn __action2< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + (_, left, _): (usize, usize, usize), (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, p, _): (usize, PeerPart<'input>, usize), @@ -2437,12 +2559,17 @@ fn __action2< (_, args, _): (usize, Vec>, usize), (_, output, _): (usize, core::option::Option>, usize), (_, _, _): (usize, Token<'input>, usize), + (_, right, _): (usize, usize, usize), ) -> Box> { { let output = output.unwrap_or(CallOutputValue::None); let args = Rc::new(args); - Box::new(Instruction::Call(Call{peer_part: p, function_part: f, args, output})) + let call = Call { peer_part: p, function_part: f, args, output }; + let span = Span { left, right }; + validator.met_call(&call, span); + + Box::new(Instruction::Call(call)) } } @@ -2450,9 +2577,11 @@ fn __action2< fn __action3< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, l, _): (usize, Box>, usize), @@ -2467,9 +2596,11 @@ fn __action3< fn __action4< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, l, _): (usize, Box>, usize), @@ -2484,9 +2615,11 @@ fn __action4< fn __action5< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Token<'input>, usize), (_, __1, _): (usize, Token<'input>, usize), (_, __2, _): (usize, Token<'input>, usize), @@ -2499,20 +2632,28 @@ fn __action5< fn __action6< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + (_, left, _): (usize, usize, usize), (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, iterable, _): (usize, IterableValue<'input>, usize), (_, iterator, _): (usize, &'input str, usize), (_, i, _): (usize, Box>, usize), (_, _, _): (usize, Token<'input>, usize), + (_, right, _): (usize, usize, usize), ) -> Box> { { let instruction = Rc::new(*i); - Box::new(Instruction::Fold(Fold{ iterable, iterator, instruction })) + let fold = Fold { iterable, iterator, instruction }; + let span = Span { left, right }; + validator.met_fold(&fold, span); + + Box::new(Instruction::Fold(fold)) } } @@ -2520,25 +2661,37 @@ fn __action6< fn __action7< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + (_, left, _): (usize, usize, usize), (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, i, _): (usize, &'input str, usize), (_, _, _): (usize, Token<'input>, usize), + (_, right, _): (usize, usize, usize), ) -> Box> { - Box::new(Instruction::Next(Next(i))) + { + let next = Next(i); + let span = Span { left, right }; + validator.met_next(&next, span); + + Box::new(Instruction::Next(next)) + } } #[allow(unused_variables)] fn __action8< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, l, _): (usize, Box>, usize), @@ -2553,9 +2706,11 @@ fn __action8< fn __action9< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, l, _): (usize, MatchableValue<'input>, usize), @@ -2574,9 +2729,11 @@ fn __action9< fn __action10< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, _, _): (usize, Token<'input>, usize), (_, l, _): (usize, MatchableValue<'input>, usize), @@ -2595,10 +2752,12 @@ fn __action10< fn __action11< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, - (_, __0, _): (usize, __lalrpop_util::ErrorRecovery, LexerError>, usize), + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + (_, __0, _): (usize, __lalrpop_util::ErrorRecovery, ParserError>, usize), ) -> Box> { { errors.push(__0); Box::new(Instruction::Error) } @@ -2608,9 +2767,11 @@ fn __action11< fn __action12< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, args, _): (usize, alloc::vec::Vec>, usize), (_, _, _): (usize, Token<'input>, usize), @@ -2623,9 +2784,11 @@ fn __action12< fn __action13< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, f, _): (usize, CallInstrValue<'input>, usize), ) -> FunctionPart<'input> { @@ -2636,9 +2799,11 @@ fn __action13< fn __action14< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, sid, _): (usize, CallInstrValue<'input>, usize), (_, f, _): (usize, CallInstrValue<'input>, usize), @@ -2652,9 +2817,11 @@ fn __action14< fn __action15< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, pid, _): (usize, CallInstrValue<'input>, usize), ) -> PeerPart<'input> { @@ -2665,9 +2832,11 @@ fn __action15< fn __action16< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, _, _): (usize, Token<'input>, usize), (_, pid, _): (usize, CallInstrValue<'input>, usize), (_, sid, _): (usize, CallInstrValue<'input>, usize), @@ -2681,9 +2850,11 @@ fn __action16< fn __action17< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> CallOutputValue<'input> { @@ -2694,9 +2865,11 @@ fn __action17< fn __action18< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, a, _): (usize, &'input str, usize), ) -> CallOutputValue<'input> { @@ -2707,9 +2880,11 @@ fn __action18< fn __action19< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrValue<'input>, usize), ) -> CallInstrValue<'input> { @@ -2720,9 +2895,11 @@ fn __action19< fn __action20< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrValue<'input>, usize), ) -> CallInstrValue<'input> { @@ -2733,9 +2910,11 @@ fn __action20< fn __action21< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrValue<'input>, usize), ) -> CallInstrValue<'input> { @@ -2746,9 +2925,11 @@ fn __action21< fn __action22< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> CallInstrValue<'input> { @@ -2759,9 +2940,11 @@ fn __action22< fn __action23< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> CallInstrValue<'input> { @@ -2772,9 +2955,11 @@ fn __action23< fn __action24< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, l, _): (usize, usize, usize), (_, v, _): (usize, (&'input str, usize, bool), usize), (_, r, _): (usize, usize, usize), @@ -2795,9 +2980,11 @@ fn __action24< fn __action25< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Token<'input>, usize), ) -> CallInstrValue<'input> { @@ -2808,9 +2995,11 @@ fn __action25< fn __action26< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrArgValue<'input>, usize), ) -> CallInstrArgValue<'input> { @@ -2821,9 +3010,11 @@ fn __action26< fn __action27< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> CallInstrArgValue<'input> { @@ -2834,9 +3025,11 @@ fn __action27< fn __action28< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> CallInstrArgValue<'input> { @@ -2847,9 +3040,11 @@ fn __action28< fn __action29< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, v, _): (usize, (&'input str, usize, bool), usize), ) -> CallInstrArgValue<'input> { @@ -2864,9 +3059,11 @@ fn __action29< fn __action30< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, n, _): (usize, Number, usize), ) -> CallInstrArgValue<'input> { @@ -2877,9 +3074,11 @@ fn __action30< fn __action31< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, b, _): (usize, bool, usize), ) -> CallInstrArgValue<'input> { @@ -2890,9 +3089,11 @@ fn __action31< fn __action32< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Token<'input>, usize), ) -> CallInstrArgValue<'input> { @@ -2903,9 +3104,11 @@ fn __action32< fn __action33< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, Token<'input>, usize), ) -> CallInstrArgValue<'input> { @@ -2916,9 +3119,11 @@ fn __action33< fn __action34< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> IterableValue<'input> { @@ -2929,14 +3134,17 @@ fn __action34< fn __action35< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, v, _): (usize, (&'input str, usize, bool), usize), ) -> IterableValue<'input> { { let (variable, path) = into_variable_and_path(v.0, v.1, v.2); + let should_flatten = v.2; IterableValue::JsonPath { variable, path, should_flatten } } @@ -2946,9 +3154,11 @@ fn __action35< fn __action36< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> MatchableValue<'input> { @@ -2959,9 +3169,11 @@ fn __action36< fn __action37< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, s, _): (usize, &'input str, usize), ) -> MatchableValue<'input> { @@ -2972,9 +3184,11 @@ fn __action37< fn __action38< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, v, _): (usize, (&'input str, usize, bool), usize), ) -> MatchableValue<'input> { @@ -2989,37 +3203,11 @@ fn __action38< fn __action39< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, - __lookbehind: &usize, - __lookahead: &usize, -) -> usize -{ - __lookbehind.clone() -} - -#[allow(unused_variables)] -fn __action40< - 'err, - 'input, ->( - input: &'input str, - errors: &'err mut Vec, LexerError>>, - __lookbehind: &usize, - __lookahead: &usize, -) -> usize -{ - __lookahead.clone() -} - -#[allow(unused_variables)] -fn __action41< - 'err, - 'input, ->( - input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookbehind: &usize, __lookahead: &usize, ) -> alloc::vec::Vec> @@ -3028,12 +3216,14 @@ fn __action41< } #[allow(unused_variables)] -fn __action42< +fn __action40< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, v, _): (usize, alloc::vec::Vec>, usize), ) -> alloc::vec::Vec> { @@ -3041,12 +3231,14 @@ fn __action42< } #[allow(unused_variables)] -fn __action43< +fn __action41< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrArgValue<'input>, usize), ) -> CallInstrArgValue<'input> { @@ -3054,12 +3246,30 @@ fn __action43< } #[allow(unused_variables)] -fn __action44< +fn __action42< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __lookbehind: &usize, + __lookahead: &usize, +) -> usize +{ + __lookbehind.clone() +} + +#[allow(unused_variables)] +fn __action43< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallOutputValue<'input>, usize), ) -> core::option::Option> { @@ -3067,12 +3277,14 @@ fn __action44< } #[allow(unused_variables)] -fn __action45< +fn __action44< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __lookbehind: &usize, __lookahead: &usize, ) -> core::option::Option> @@ -3080,13 +3292,31 @@ fn __action45< None } +#[allow(unused_variables)] +fn __action45< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __lookbehind: &usize, + __lookahead: &usize, +) -> usize +{ + __lookahead.clone() +} + #[allow(unused_variables)] fn __action46< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, __0, _): (usize, CallInstrArgValue<'input>, usize), ) -> alloc::vec::Vec> { @@ -3097,9 +3327,11 @@ fn __action46< fn __action47< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, (_, v, _): (usize, alloc::vec::Vec>, usize), (_, e, _): (usize, CallInstrArgValue<'input>, usize), ) -> alloc::vec::Vec> @@ -3111,23 +3343,27 @@ fn __action47< fn __action48< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, CallInstrArgValue<'input>, usize), ) -> alloc::vec::Vec> { let __start0 = __0.0.clone(); let __end0 = __0.2.clone(); - let __temp0 = __action43( + let __temp0 = __action41( input, errors, + validator, __0, ); let __temp0 = (__start0, __temp0, __end0); __action46( input, errors, + validator, __temp0, ) } @@ -3136,24 +3372,28 @@ fn __action48< fn __action49< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, alloc::vec::Vec>, usize), __1: (usize, CallInstrArgValue<'input>, usize), ) -> alloc::vec::Vec> { let __start0 = __1.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action43( + let __temp0 = __action41( input, errors, + validator, __1, ); let __temp0 = (__start0, __temp0, __end0); __action47( input, errors, + validator, __0, __temp0, ) @@ -3163,18 +3403,21 @@ fn __action49< fn __action50< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, Token<'input>, usize), __1: (usize, Token<'input>, usize), ) -> Vec> { let __start0 = __0.2.clone(); let __end0 = __1.0.clone(); - let __temp0 = __action41( + let __temp0 = __action39( input, errors, + validator, &__start0, &__end0, ); @@ -3182,6 +3425,7 @@ fn __action50< __action12( input, errors, + validator, __0, __temp0, __1, @@ -3192,9 +3436,11 @@ fn __action50< fn __action51< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, Token<'input>, usize), __1: (usize, alloc::vec::Vec>, usize), __2: (usize, Token<'input>, usize), @@ -3202,15 +3448,17 @@ fn __action51< { let __start0 = __1.0.clone(); let __end0 = __1.2.clone(); - let __temp0 = __action42( + let __temp0 = __action40( input, errors, + validator, __1, ); let __temp0 = (__start0, __temp0, __end0); __action12( input, errors, + validator, __0, __temp0, __2, @@ -3221,18 +3469,21 @@ fn __action51< fn __action52< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, (&'input str, usize, bool), usize), __1: (usize, usize, usize), ) -> CallInstrValue<'input> { let __start0 = __0.0.clone(); let __end0 = __0.0.clone(); - let __temp0 = __action40( + let __temp0 = __action45( input, errors, + validator, &__start0, &__end0, ); @@ -3240,6 +3491,7 @@ fn __action52< __action24( input, errors, + validator, __temp0, __0, __1, @@ -3250,26 +3502,44 @@ fn __action52< fn __action53< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, - __0: (usize, (&'input str, usize, bool), usize), -) -> CallInstrValue<'input> + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, PeerPart<'input>, usize), + __3: (usize, FunctionPart<'input>, usize), + __4: (usize, Vec>, usize), + __5: (usize, core::option::Option>, usize), + __6: (usize, Token<'input>, usize), + __7: (usize, usize, usize), +) -> Box> { - let __start0 = __0.2.clone(); - let __end0 = __0.2.clone(); - let __temp0 = __action39( + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action45( input, errors, + validator, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action52( + __action2( input, errors, - __0, + validator, __temp0, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __7, ) } @@ -3277,9 +3547,245 @@ fn __action53< fn __action54< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, IterableValue<'input>, usize), + __3: (usize, &'input str, usize), + __4: (usize, Box>, usize), + __5: (usize, Token<'input>, usize), + __6: (usize, usize, usize), +) -> Box> +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action45( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action6( + input, + errors, + validator, + __temp0, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + ) +} + +#[allow(unused_variables)] +fn __action55< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, &'input str, usize), + __3: (usize, Token<'input>, usize), + __4: (usize, usize, usize), +) -> Box> +{ + let __start0 = __0.0.clone(); + let __end0 = __0.0.clone(); + let __temp0 = __action45( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action7( + input, + errors, + validator, + __temp0, + __0, + __1, + __2, + __3, + __4, + ) +} + +#[allow(unused_variables)] +fn __action56< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, (&'input str, usize, bool), usize), +) -> CallInstrValue<'input> +{ + let __start0 = __0.2.clone(); + let __end0 = __0.2.clone(); + let __temp0 = __action42( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action52( + input, + errors, + validator, + __0, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action57< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, PeerPart<'input>, usize), + __3: (usize, FunctionPart<'input>, usize), + __4: (usize, Vec>, usize), + __5: (usize, core::option::Option>, usize), + __6: (usize, Token<'input>, usize), +) -> Box> +{ + let __start0 = __6.2.clone(); + let __end0 = __6.2.clone(); + let __temp0 = __action42( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action53( + input, + errors, + validator, + __0, + __1, + __2, + __3, + __4, + __5, + __6, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action58< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, IterableValue<'input>, usize), + __3: (usize, &'input str, usize), + __4: (usize, Box>, usize), + __5: (usize, Token<'input>, usize), +) -> Box> +{ + let __start0 = __5.2.clone(); + let __end0 = __5.2.clone(); + let __temp0 = __action42( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action54( + input, + errors, + validator, + __0, + __1, + __2, + __3, + __4, + __5, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action59< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, + __0: (usize, Token<'input>, usize), + __1: (usize, Token<'input>, usize), + __2: (usize, &'input str, usize), + __3: (usize, Token<'input>, usize), +) -> Box> +{ + let __start0 = __3.2.clone(); + let __end0 = __3.2.clone(); + let __temp0 = __action42( + input, + errors, + validator, + &__start0, + &__end0, + ); + let __temp0 = (__start0, __temp0, __end0); + __action55( + input, + errors, + validator, + __0, + __1, + __2, + __3, + __temp0, + ) +} + +#[allow(unused_variables)] +fn __action60< + 'err, + 'input, + 'v, +>( + input: &'input str, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, Token<'input>, usize), __1: (usize, Token<'input>, usize), __2: (usize, PeerPart<'input>, usize), @@ -3291,15 +3797,17 @@ fn __action54< { let __start0 = __5.0.clone(); let __end0 = __5.2.clone(); - let __temp0 = __action44( + let __temp0 = __action43( input, errors, + validator, __5, ); let __temp0 = (__start0, __temp0, __end0); - __action2( + __action57( input, errors, + validator, __0, __1, __2, @@ -3311,12 +3819,14 @@ fn __action54< } #[allow(unused_variables)] -fn __action55< +fn __action61< 'err, 'input, + 'v, >( input: &'input str, - errors: &'err mut Vec, LexerError>>, + errors: &'err mut Vec, ParserError>>, + validator: &'v mut VariableValidator<'input>, __0: (usize, Token<'input>, usize), __1: (usize, Token<'input>, usize), __2: (usize, PeerPart<'input>, usize), @@ -3327,16 +3837,18 @@ fn __action55< { let __start0 = __4.2.clone(); let __end0 = __5.0.clone(); - let __temp0 = __action45( + let __temp0 = __action44( input, errors, + validator, &__start0, &__end0, ); let __temp0 = (__start0, __temp0, __end0); - __action2( + __action57( input, errors, + validator, __0, __1, __2, @@ -3347,17 +3859,17 @@ fn __action55< ) } -pub trait __ToTriple<'err, 'input, > { - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, LexerError>>; +pub trait __ToTriple<'err, 'input, 'v, > { + fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, ParserError>>; } -impl<'err, 'input, > __ToTriple<'err, 'input, > for (usize, Token<'input>, usize) { - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, LexerError>> { +impl<'err, 'input, 'v, > __ToTriple<'err, 'input, 'v, > for (usize, Token<'input>, usize) { + fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, ParserError>> { Ok(value) } } -impl<'err, 'input, > __ToTriple<'err, 'input, > for Result<(usize, Token<'input>, usize), LexerError> { - fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, LexerError>> { +impl<'err, 'input, 'v, > __ToTriple<'err, 'input, 'v, > for Result<(usize, Token<'input>, usize), ParserError> { + fn to_triple(value: Self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, ParserError>> { match value { Ok(v) => Ok(v), Err(error) => Err(__lalrpop_util::ParseError::User { error }), diff --git a/crates/air-parser/src/parser/air_parser.rs b/crates/air-parser/src/parser/air_parser.rs index dd5b342d..713e26e8 100644 --- a/crates/air-parser/src/parser/air_parser.rs +++ b/crates/air-parser/src/parser/air_parser.rs @@ -19,6 +19,10 @@ use super::ast::Instruction; use super::lexer::AIRLexer; use super::lexer::LexerError; use super::lexer::Token; +use super::ParserError; + +use crate::parser::VariableValidator; +use air::AIRParser; use codespan_reporting::diagnostic::{Diagnostic, Label}; use codespan_reporting::files::SimpleFiles; @@ -26,8 +30,6 @@ use codespan_reporting::term; use codespan_reporting::term::termcolor::{Buffer, ColorChoice, StandardStream}; use lalrpop_util::{ErrorRecovery, ParseError}; -use air::AIRParser; - // Caching parser to cache internal regexes, which are expensive to instantiate // See also https://github.com/lalrpop/lalrpop/issues/269 thread_local!(static PARSER: AIRParser = AIRParser::new()); @@ -40,7 +42,13 @@ pub fn parse(air_script: &str) -> Result>, String> { PARSER.with(|parser| { let mut errors = Vec::new(); let lexer = AIRLexer::new(air_script); - match parser.parse(air_script, &mut errors, lexer) { + let mut validator = VariableValidator::new(); + let result = parser.parse(air_script, &mut errors, &mut validator, lexer); + + let validator_errors = validator.finalize(); + errors.extend(validator_errors); + + match result { Ok(r) if errors.is_empty() => Ok(r), Ok(_) => Err(report_errors(file_id, files, errors)), Err(err) => Err(report_errors( @@ -58,7 +66,7 @@ pub fn parse(air_script: &str) -> Result>, String> { fn report_errors( file_id: usize, files: SimpleFiles<&str, &str>, - errors: Vec, LexerError>>, + errors: Vec, ParserError>>, ) -> String { let labels = errors_to_labels(file_id, errors); let diagnostic = Diagnostic::error().with_labels(labels); @@ -78,7 +86,7 @@ fn report_errors( fn errors_to_labels( file_id: usize, - errors: Vec, LexerError>>, + errors: Vec, ParserError>>, ) -> Vec> { errors .into_iter() @@ -98,7 +106,7 @@ fn errors_to_labels( Label::primary(file_id, location..(location + 1)) .with_message(format!("expected {}", pretty_expected(expected))) } - ParseError::User { error } => lexical_error_to_label(file_id, error), + ParseError::User { error } => parser_error_to_label(file_id, error), }) .collect() } @@ -111,6 +119,23 @@ fn pretty_expected(expected: Vec) -> String { } } +fn parser_error_to_label(file_id: usize, error: ParserError) -> Label { + use ParserError::*; + + match error { + LexerError(error) => lexical_error_to_label(file_id, error), + CallArgsNotFlattened(start, end) => { + Label::primary(file_id, start..end).with_message(error.to_string()) + } + UndefinedIterable(start, end, _) => { + Label::primary(file_id, start..end).with_message(error.to_string()) + } + UndefinedVariable(start, end, _) => { + Label::primary(file_id, start..end).with_message(error.to_string()) + } + } +} + fn lexical_error_to_label(file_id: usize, error: LexerError) -> Label { use LexerError::*; match error { @@ -147,9 +172,6 @@ fn lexical_error_to_label(file_id: usize, error: LexerError) -> Label { LeadingDot(start, end) => { Label::primary(file_id, start..end).with_message(error.to_string()) } - CallArgsNotFlattened(start, end) => { - Label::primary(file_id, start..end).with_message(error.to_string()) - } } } @@ -167,8 +189,8 @@ pub(super) fn make_flattened_error( start_pos: usize, token: Token<'_>, end_pos: usize, -) -> ErrorRecovery, LexerError> { - let error = LexerError::CallArgsNotFlattened(start_pos, end_pos); +) -> ErrorRecovery, ParserError> { + let error = ParserError::CallArgsNotFlattened(start_pos, end_pos); let error = ParseError::User { error }; let dropped_tokens = vec![(start_pos, token, end_pos)]; diff --git a/crates/air-parser/src/parser/errors.rs b/crates/air-parser/src/parser/errors.rs new file mode 100644 index 00000000..a776870c --- /dev/null +++ b/crates/air-parser/src/parser/errors.rs @@ -0,0 +1,39 @@ +/* + * Copyright 2020 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use crate::parser::lexer::LexerError; +use thiserror::Error as ThisError; + +#[derive(ThisError, Debug, Clone, PartialEq, Eq)] +pub enum ParserError { + #[error("{0}")] + LexerError(#[from] LexerError), + + #[error("while using json path in call triplet, result should be flattened, add ! at the end")] + CallArgsNotFlattened(usize, usize), + + #[error("variable '{2}' wasn't defined")] + UndefinedVariable(usize, usize, String), + + #[error("iterable '{2}' wasn't defined")] + UndefinedIterable(usize, usize, String), +} + +impl From for ParserError { + fn from(_: std::convert::Infallible) -> Self { + unreachable!() + } +} diff --git a/crates/air-parser/src/parser/lexer/errors.rs b/crates/air-parser/src/parser/lexer/errors.rs index 2e979153..ad1fc5ea 100644 --- a/crates/air-parser/src/parser/lexer/errors.rs +++ b/crates/air-parser/src/parser/lexer/errors.rs @@ -53,9 +53,29 @@ pub enum LexerError { #[error("leading dot without any symbols before - please write 0 if it's float or variable name if it's json path")] LeadingDot(usize, usize), +} - #[error("while using json path in call triplet, result should be flattened, add ! at the end")] - CallArgsNotFlattened(usize, usize), +use super::Token; +use crate::parser::air::__ToTriple; +use crate::parser::ParserError; + +impl<'err, 'input, 'i> __ToTriple<'err, 'input, 'i> + for Result<(usize, Token<'input>, usize), LexerError> +{ + fn to_triple( + value: Self, + ) -> Result< + (usize, Token<'input>, usize), + lalrpop_util::ParseError, ParserError>, + > { + match value { + Ok(v) => Ok(v), + Err(error) => { + let error = ParserError::LexerError(error); + Err(lalrpop_util::ParseError::User { error }) + } + } + } } impl From for LexerError { diff --git a/crates/air-parser/src/parser/mod.rs b/crates/air-parser/src/parser/mod.rs index 0bf2c875..62cb317a 100644 --- a/crates/air-parser/src/parser/mod.rs +++ b/crates/air-parser/src/parser/mod.rs @@ -23,6 +23,8 @@ mod lexer; mod air; pub mod ast; +mod errors; +mod validator; #[cfg(test)] pub mod tests; @@ -30,3 +32,12 @@ pub mod tests; pub use self::air_parser::parse; pub use air::AIRParser; pub use lexer::AIRLexer; + +use errors::ParserError; +use validator::VariableValidator; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Span { + pub left: usize, + pub right: usize, +} diff --git a/crates/air-parser/src/parser/tests.rs b/crates/air-parser/src/parser/tests.rs index 78227e53..6f93eb97 100644 --- a/crates/air-parser/src/parser/tests.rs +++ b/crates/air-parser/src/parser/tests.rs @@ -15,13 +15,25 @@ */ use crate::ast; +use crate::parser::AIRParser; +use crate::parser::ParserError; use ast::Instruction; use fstrings::f; +use lalrpop_util::ParseError; use std::rc::Rc; +thread_local!(static TEST_PARSER: AIRParser = AIRParser::new()); + fn parse(source_code: &str) -> Instruction { - *crate::parse(source_code).expect("parsing failed") + *TEST_PARSER.with(|parser| { + let mut errors = Vec::new(); + let lexer = crate::parser::AIRLexer::new(source_code); + let mut validator = crate::parser::VariableValidator::new(); + parser + .parse(source_code, &mut errors, &mut validator, lexer) + .expect("parsing should be successfull") + }) } #[test] @@ -143,7 +155,7 @@ fn parse_json_path() { } #[test] -fn parse_json_path_without_flattening() { +fn parse_undefined_variable() { let source_code = r#" (call id.$.a "f" ["hello" name] void[]) "#; @@ -152,12 +164,59 @@ fn parse_json_path_without_flattening() { let parser = crate::AIRParser::new(); let mut errors = Vec::new(); + let mut validator = super::VariableValidator::new(); parser - .parse(source_code, &mut errors, lexer) + .parse(source_code, &mut errors, &mut validator, lexer) .expect("parser shoudn't fail"); + let errors = validator.finalize(); + + assert_eq!(errors.len(), 2); + for i in 0..2 { + let error = &errors[i].error; + let parser_error = match error { + ParseError::User { error } => error, + _ => panic!("unexpected error type"), + }; + + assert!(matches!(parser_error, ParserError::UndefinedVariable(..))); + } +} + +#[test] +fn parse_undefined_iterable() { + let source_code = r#" + (seq + (call "" ("" "") [] iterable) + (fold iterable i + (seq + (call "" ("" "") ["hello" ""] void[]) + (next j) + ) + ) + ) + "#; + + let lexer = crate::AIRLexer::new(source_code); + + let parser = crate::AIRParser::new(); + let mut errors = Vec::new(); + let mut validator = super::VariableValidator::new(); + parser + .parse(source_code, &mut errors, &mut validator, lexer) + .expect("parser shoudn't fail"); + + let errors = validator.finalize(); + assert_eq!(errors.len(), 1); - assert!(matches!(errors[0], lalrpop_util::ErrorRecovery { .. })); + + let error = &errors[0].error; + let parser_error = match error { + ParseError::User { error } => error, + _ => panic!("unexpected error type"), + }; + + assert!(matches!(parser_error, ParserError::UndefinedIterable(..))); } #[test] diff --git a/crates/air-parser/src/parser/validator.rs b/crates/air-parser/src/parser/validator.rs new file mode 100644 index 00000000..db21fc07 --- /dev/null +++ b/crates/air-parser/src/parser/validator.rs @@ -0,0 +1,239 @@ +/* + * Copyright 2020 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +use super::ast::*; + +use crate::parser::lexer::Token; +use crate::parser::ParserError; +use crate::parser::Span; + +use lalrpop_util::ErrorRecovery; +use lalrpop_util::ParseError; + +use multimap::MultiMap; +use std::collections::HashMap; + +/// Intermediate implementation of variable validator. +/// +/// It is intended to track variables (i.e., those that were defined as +/// a result of the `call` instruction) and iterables (i.e., those X's defined +/// in a `fold array X` call). +/// +/// Validator will catch any undefined variables or iterables and raise an error. +#[derive(Debug, Default, Clone)] +pub struct VariableValidator<'i> { + /// Contains the most left definition of a variables met in call outputs. + met_variables: HashMap<&'i str, Span>, + + /// Contains iterables met in fold iterables. + met_iterators: MultiMap<&'i str, Span>, + + /// These variables from calls and folds haven't been resolved at the first meet. + unresolved_variables: MultiMap<&'i str, Span>, + + /// Contains all met iterable in call and next, they will be resolved after the whole parsing + /// due to the way how lalrpop work. + unresolved_iterables: MultiMap<&'i str, Span>, +} + +impl<'i> VariableValidator<'i> { + pub(super) fn new() -> Self { + <_>::default() + } + + pub(super) fn met_call(&mut self, call: &Call<'i>, span: Span) { + self.met_peer_part(&call.peer_part, span); + self.met_function_part(&call.function_part, span); + self.met_args(&call.args, span); + self.met_call_output_definition(&call.output, span) + } + + pub(super) fn met_fold(&mut self, fold: &Fold<'i>, span: Span) { + self.met_iterable_value(&fold.iterable, span); + self.met_iterator_definition(&fold.iterator, span); + } + + pub(super) fn met_next(&mut self, next: &Next<'i>, span: Span) { + let iterable_name = next.0; + // due to the right to left convolution in lalrpop, next will be met earlier than + // a corresponding fold with the definition of this iterable, so they're just put + // without a check for being already met + self.unresolved_iterables.insert(iterable_name, span); + } + + pub(super) fn finalize<'err>(&self) -> Vec, ParserError>> { + let mut errors = Vec::new(); + for (name, span) in self.unresolved_variables.iter() { + if !self.contains_variable(name, *span) { + add_to_errors(*name, &mut errors, *span, Token::Call); + } + } + + for (name, span) in self.unresolved_iterables.iter() { + if !self.contains_iterable(name, *span) { + add_to_errors(*name, &mut errors, *span, Token::Next); + } + } + + errors + } + + fn met_peer_part(&mut self, peer_part: &PeerPart<'i>, span: Span) { + match peer_part { + PeerPart::PeerPk(peer_pk) => self.met_instr_value(peer_pk, span), + PeerPart::PeerPkWithServiceId(peer_pk, service_id) => { + self.met_instr_value(peer_pk, span); + self.met_instr_value(service_id, span); + } + } + } + + fn met_function_part(&mut self, function_part: &FunctionPart<'i>, span: Span) { + match function_part { + FunctionPart::FuncName(func_name) => self.met_instr_value(func_name, span), + FunctionPart::ServiceIdWithFuncName(service_id, func_name) => { + self.met_instr_value(service_id, span); + self.met_instr_value(func_name, span); + } + } + } + + fn met_args(&mut self, args: &[CallInstrArgValue<'i>], span: Span) { + for arg in args { + self.met_instr_arg_value(arg, span); + } + } + + fn met_instr_value(&mut self, instr_value: &CallInstrValue<'i>, span: Span) { + match instr_value { + CallInstrValue::JsonPath { variable, .. } => self.met_variable(variable, span), + CallInstrValue::Variable(variable) => self.met_variable(variable, span), + _ => {} + } + } + + fn met_instr_arg_value(&mut self, instr_arg_value: &CallInstrArgValue<'i>, span: Span) { + match instr_arg_value { + CallInstrArgValue::JsonPath { variable, .. } => self.met_variable(variable, span), + CallInstrArgValue::Variable(variable) => self.met_variable(variable, span), + _ => {} + } + } + + fn met_variable(&mut self, name: &'i str, span: Span) { + if !self.contains_variable(name, span) { + self.unresolved_variables.insert(name, span); + } + } + + fn contains_variable(&self, key: &str, key_span: Span) -> bool { + if let Some(found_span) = self.met_variables.get(key) { + if found_span < &key_span { + return true; + } + } + + let found_spans = match self.met_iterators.get_vec(key) { + Some(found_spans) => found_spans, + None => return false, + }; + + found_spans.iter().any(|s| s < &key_span) + } + + fn met_call_output_definition(&mut self, call_output: &CallOutputValue<'i>, span: Span) { + use std::collections::hash_map::Entry; + + let variable_name = match call_output { + CallOutputValue::Scalar(variable) => variable, + CallOutputValue::Accumulator(accumulator) => accumulator, + CallOutputValue::None => return, + }; + + match self.met_variables.entry(variable_name) { + Entry::Occupied(occupied) => { + if occupied.get() > &span { + *occupied.into_mut() = span; + } + } + Entry::Vacant(vacant) => { + vacant.insert(span); + } + } + } + + /// Checks that multimap contains a span for given key such that provided span lies inside it. + fn contains_iterable(&self, key: &str, key_span: Span) -> bool { + let found_spans = match self.met_iterators.get_vec(key) { + Some(found_spans) => found_spans, + None => return false, + }; + + found_spans + .iter() + .any(|s| s.left < key_span.left && s.right > key_span.right) + } + + fn met_iterable_value(&mut self, iterable_value: &IterableValue<'i>, span: Span) { + match iterable_value { + IterableValue::JsonPath { variable, .. } => self.met_variable(variable, span), + IterableValue::Variable(variable) => self.met_variable(variable, span), + } + } + + fn met_iterator_definition(&mut self, iterator: &'i str, span: Span) { + self.met_iterators.insert(iterator, span); + } +} + +use std::cmp::Ordering; +impl PartialOrd for Span { + fn partial_cmp(&self, other: &Self) -> Option { + let self_min = std::cmp::min(self.left, self.right); + let other_min = std::cmp::min(other.left, other.right); + + if self_min < other_min { + Some(Ordering::Less) + } else if self == other { + Some(Ordering::Equal) + } else { + Some(Ordering::Greater) + } + } +} + +fn add_to_errors<'err, 'i>( + variable_name: impl Into, + errors: &'err mut Vec, ParserError>>, + span: Span, + token: Token<'i>, +) { + let variable_name = variable_name.into(); + let error = match token { + Token::Next => ParserError::UndefinedIterable(span.left, span.right, variable_name), + _ => ParserError::UndefinedVariable(span.left, span.right, variable_name), + }; + let error = ParseError::User { error }; + + let dropped_tokens = vec![(span.left, token, span.right)]; + + let error = ErrorRecovery { + error, + dropped_tokens, + }; + + errors.push(error); +} diff --git a/interpreter-lib/src/execution/air/call.rs b/interpreter-lib/src/execution/air/call.rs index 533948e8..15ffec59 100644 --- a/interpreter-lib/src/execution/air/call.rs +++ b/interpreter-lib/src/execution/air/call.rs @@ -175,7 +175,7 @@ mod tests { let remote_peer_id = String::from("some_remote_peer_id"); let script = format!( - r#"(call "{}" ("local_service_id" "local_fn_name") [value] result_name)"#, + r#"(call "{}" ("local_service_id" "local_fn_name") ["arg"] result_name)"#, remote_peer_id ); diff --git a/interpreter-lib/src/execution/air/fold.rs b/interpreter-lib/src/execution/air/fold.rs index e33c505b..37d74e6f 100644 --- a/interpreter-lib/src/execution/air/fold.rs +++ b/interpreter-lib/src/execution/air/fold.rs @@ -347,9 +347,6 @@ mod tests { // Check that fold works with the join behaviour without hanging up. #[test] fn fold_with_join() { - use crate::contexts::execution_trace::CallResult::*; - use crate::contexts::execution_trace::ExecutedState::*; - let mut vm = create_aqua_vm(echo_number_call_service(), "A"); let mut set_variable_vm = create_aqua_vm(set_variable_call_service(r#"["1","2"]"#), "set_variable"); @@ -357,10 +354,13 @@ mod tests { r#" (seq (call "set_variable" ("" "") [] iterable) - (fold iterable i - (seq - (call "A" ("" "") [non_exist_variable.$.hash!] acc[]) - (next i) + (par + (call "unknown_peer" ("" "") [] lazy_def_variable) + (fold iterable i + (seq + (call "A" ("" "") [lazy_def_variable.$.hash!] acc[]) + (next i) + ) ) ) )"#, @@ -370,8 +370,7 @@ mod tests { let res = call_vm!(vm, "", fold_with_join, "", res.data); let res: ExecutionTrace = serde_json::from_slice(&res.data).expect("should be valid executed trace"); - assert_eq!(res.len(), 1); - assert_eq!(res[0], Call(Executed(Rc::new(json!(["1", "2"]))))); + assert_eq!(res.len(), 3); } #[test] diff --git a/interpreter-lib/src/execution/air/xor.rs b/interpreter-lib/src/execution/air/xor.rs index 421fb4ce..663639a1 100644 --- a/interpreter-lib/src/execution/air/xor.rs +++ b/interpreter-lib/src/execution/air/xor.rs @@ -104,6 +104,8 @@ mod tests { #[test] fn xor_var_not_found() { + use crate::contexts::execution_trace::CallResult::*; + use crate::contexts::execution_trace::ExecutedState::*; use aqua_test_utils::echo_string_call_service; let local_peer_id = "local_peer_id"; @@ -112,7 +114,10 @@ mod tests { let script = format!( r#" (xor - (call "{0}" ("service_id_1" "local_fn_name") [non_existent_variable] result) + (par + (call "unknown_peer" ("service_id_1" "local_fn_name") [] lazy_defined_variable) + (call "{0}" ("service_id_1" "local_fn_name") [lazy_defined_variable] result) + ) (call "{0}" ("service_id_2" "local_fn_name") ["expected"] result) )"#, local_peer_id, @@ -120,9 +125,8 @@ mod tests { let res = call_vm!(vm, "asd", script, "[]", "[]"); let actual_trace: ExecutionTrace = serde_json::from_slice(&res.data).expect("should be valid json"); - - assert!(actual_trace.is_empty()); - assert!(res.next_peer_pks.is_empty()); + assert_eq!(actual_trace[0], Par(1, 0)); + assert_eq!(actual_trace[1], Call(RequestSentBy(String::from("local_peer_id")))); } #[test]