From b21a98aa6741cca618e7287e727cb2b8334bd8ca Mon Sep 17 00:00:00 2001 From: Philipp Degler Date: Mon, 10 Oct 2022 10:04:04 +0200 Subject: [PATCH 1/2] update parking lot and remove warnings --- Cargo.toml | 2 +- src/lib.rs | 1 - tests/gen/labelsparser.rs | 2 +- tests/gen/referencetoatnparser.rs | 4 ++-- tests/gen/simplelrparser.rs | 2 +- tests/my_test.rs | 2 +- tests/perf.rs | 1 - 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aa0633c..246fd2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ once_cell = "^1.2" #backtrace = "=0.3" typed-arena = "^2.0" better_any = "=0.1" -parking_lot = "0.11" +parking_lot = "0.12" #qcell = { path="../qcell" } [lib] diff --git a/src/lib.rs b/src/lib.rs index d3fcce4..4cc2ea5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,6 @@ #![feature(specialization)] #![feature(coerce_unsized)] #![feature(associated_type_defaults)] -#![feature(generic_associated_types)] // #![feature(generic_associated_types)] #![warn(rust_2018_idioms)] #![warn(missing_docs)] // warn if there is missing docs diff --git a/tests/gen/labelsparser.rs b/tests/gen/labelsparser.rs index cff678b..a470331 100644 --- a/tests/gen/labelsparser.rs +++ b/tests/gen/labelsparser.rs @@ -1033,7 +1033,7 @@ where recog.base.set_state(36); recog.err_handler.sync(&mut recog.base)?; _alt = recog.interpreter.adaptive_predict(2, &mut recog.base)?; - while { _alt != 2 && _alt != INVALID_ALT } { + while _alt != 2 && _alt != INVALID_ALT { if _alt == 1 { recog.trigger_exit_rule_event(); _prevctx = _localctx.clone(); diff --git a/tests/gen/referencetoatnparser.rs b/tests/gen/referencetoatnparser.rs index bc310cf..5090303 100644 --- a/tests/gen/referencetoatnparser.rs +++ b/tests/gen/referencetoatnparser.rs @@ -299,13 +299,13 @@ where recog.base.set_state(5); recog.err_handler.sync(&mut recog.base)?; _alt = recog.interpreter.adaptive_predict(0, &mut recog.base)?; - while { _alt != 2 && _alt != INVALID_ALT } { + while _alt != 2 && _alt != INVALID_ALT { if _alt == 1 { { { recog.base.set_state(2); _la = recog.base.input.la(1); - if { !(_la == ID || _la == ATN) } { + if !(_la == ID || _la == ATN) { recog.err_handler.recover_inline(&mut recog.base)?; } else { if recog.base.input.la(1) == TOKEN_EOF { diff --git a/tests/gen/simplelrparser.rs b/tests/gen/simplelrparser.rs index ac75df8..1f4232b 100644 --- a/tests/gen/simplelrparser.rs +++ b/tests/gen/simplelrparser.rs @@ -406,7 +406,7 @@ where recog.base.set_state(13); recog.err_handler.sync(&mut recog.base)?; _alt = recog.interpreter.adaptive_predict(0, &mut recog.base)?; - while { _alt != 2 && _alt != INVALID_ALT } { + while _alt != 2 && _alt != INVALID_ALT { if _alt == 1 { recog.trigger_exit_rule_event(); _prevctx = _localctx.clone(); diff --git a/tests/my_test.rs b/tests/my_test.rs index 7c79311..8cc0b9b 100644 --- a/tests/my_test.rs +++ b/tests/my_test.rs @@ -1,6 +1,6 @@ #![feature(try_blocks)] #![feature(inner_deref)] -#![feature(specialization)] +#![feature(min_specialization)] #![feature(coerce_unsized)] //! Integration tests diff --git a/tests/perf.rs b/tests/perf.rs index 101b6ab..f9560b4 100644 --- a/tests/perf.rs +++ b/tests/perf.rs @@ -1,5 +1,4 @@ #![feature(try_blocks)] -#![feature(inner_deref)] #![feature(test)] #[macro_use] extern crate lazy_static; From e03a76788696aa35d98145d4ebc6a574d6b59778 Mon Sep 17 00:00:00 2001 From: Philipp Degler Date: Mon, 10 Oct 2022 10:21:07 +0200 Subject: [PATCH 2/2] use latest rust edition 2021 fix cargo format and a few clippy issues --- Cargo.toml | 2 +- build.rs | 4 +- rustfmt.toml | 4 +- src/atn.rs | 4 +- src/atn_config.rs | 24 ++--- src/atn_config_set.rs | 4 +- src/atn_deserializer.rs | 26 +---- src/atn_simulator.rs | 3 +- src/common_token_stream.rs | 3 +- src/dfa_serializer.rs | 3 +- src/error_listener.rs | 113 +++++---------------- src/error_strategy.rs | 59 ++++------- src/errors.rs | 12 +-- src/lexer.rs | 20 ++-- src/lexer_action_executor.rs | 3 +- src/lexer_atn_simulator.rs | 29 ++---- src/ll1_analyzer.rs | 5 +- src/parser.rs | 43 ++------ src/parser_atn_simulator.rs | 158 +++++++----------------------- src/parser_rule_context.rs | 6 +- src/prediction_context.rs | 26 ++--- src/prediction_mode.rs | 3 +- src/recognizer.rs | 24 ++--- src/rule_context.rs | 6 +- src/semantic_context.rs | 14 +-- src/token_factory.rs | 46 ++------- src/tree.rs | 3 +- src/vocabulary.rs | 4 +- tests/gen/csvlexer.rs | 8 +- tests/gen/csvparser.rs | 16 ++- tests/gen/labelslexer.rs | 8 +- tests/gen/labelsparser.rs | 25 ++--- tests/gen/referencetoatnlexer.rs | 8 +- tests/gen/referencetoatnparser.rs | 7 +- tests/gen/simplelrlexer.rs | 8 +- tests/gen/simplelrparser.rs | 19 ++-- tests/gen/xmllexer.rs | 20 ++-- tests/my_test.rs | 15 ++- 38 files changed, 219 insertions(+), 566 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 246fd2a..4fb9cfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/rrevenantt/antlr4rust" documentation = "https://docs.rs/antlr-rust" description = "ANTLR4 runtime for Rust" readme = "README.md" -edition = "2018" +edition = "2021" license = "BSD-3-Clause" keywords = ["ANTLR","ANTLR4","parsing","runtime"] categories = ["parsing"] diff --git a/build.rs b/build.rs index dad6347..eb3dfec 100644 --- a/build.rs +++ b/build.rs @@ -25,9 +25,7 @@ fn main() { } fn gen_for_grammar( - grammar_file_name: &str, - antlr_path: &str, - additional_arg: Option<&str>, + grammar_file_name: &str, antlr_path: &str, additional_arg: Option<&str>, ) -> Result<(), Box> { // let out_dir = env::var("OUT_DIR").unwrap(); // let dest_path = Path::new(&out_dir); diff --git a/rustfmt.toml b/rustfmt.toml index 67806f7..fcc2cc8 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,3 @@ -edition = "2018" +edition = "2021" fn_single_line = true -fn_params_layout = "Compressed" \ No newline at end of file +fn_args_layout = "Compressed" \ No newline at end of file diff --git a/src/atn.rs b/src/atn.rs index 30c8c56..3dee7cf 100644 --- a/src/atn.rs +++ b/src/atn.rs @@ -85,9 +85,7 @@ impl ATN { /// the rule surrounding `s`. In other words, the set will be /// restricted to tokens reachable staying within `s`'s rule. pub fn next_tokens_in_ctx<'a, Ctx: ParserNodeType<'a>>( - &self, - s: &dyn ATNState, - _ctx: Option<&Ctx::Type>, + &self, s: &dyn ATNState, _ctx: Option<&Ctx::Type>, ) -> IntervalSet { let analyzer = LL1Analyzer::new(self); analyzer.look::(s, None, _ctx) diff --git a/src/atn_config.rs b/src/atn_config.rs index f7d7d83..ebf1d1b 100644 --- a/src/atn_config.rs +++ b/src/atn_config.rs @@ -111,9 +111,7 @@ impl ATNConfig { } pub fn new( - state: ATNStateRef, - alt: isize, - context: Option>, + state: ATNStateRef, alt: isize, context: Option>, ) -> ATNConfig { ATNConfig { precedence_filter_suppressed: false, @@ -127,9 +125,7 @@ impl ATNConfig { } pub fn new_with_semantic( - state: ATNStateRef, - alt: isize, - context: Option>, + state: ATNStateRef, alt: isize, context: Option>, semantic_context: Box, ) -> ATNConfig { let mut new = Self::new(state, alt, context); @@ -138,9 +134,7 @@ impl ATNConfig { } pub fn new_lexer_atnconfig6( - _state: ATNStateRef, - _alt: isize, - _context: Arc, + _state: ATNStateRef, _alt: isize, _context: Arc, ) -> ATNConfig { let mut atnconfig = ATNConfig::new(_state, _alt, Some(_context)); atnconfig.config_type = ATNConfigType::LexerATNConfig { @@ -151,9 +145,7 @@ impl ATNConfig { } pub fn cloned_with_new_semantic( - &self, - target: &dyn ATNState, - ctx: Box, + &self, target: &dyn ATNState, ctx: Box, ) -> ATNConfig { let mut new = self.cloned(target); new.semantic_context = ctx; @@ -175,9 +167,7 @@ impl ATNConfig { } pub fn cloned_with_new_ctx( - &self, - target: &dyn ATNState, - ctx: Option>, + &self, target: &dyn ATNState, ctx: Option>, ) -> ATNConfig { let mut new = self.cloned(target); new.context = ctx; @@ -186,9 +176,7 @@ impl ATNConfig { } pub(crate) fn cloned_with_new_exec( - &self, - target: &dyn ATNState, - exec: Option, + &self, target: &dyn ATNState, exec: Option, ) -> ATNConfig { let mut new = self.cloned(target); if let ATNConfigType::LexerATNConfig { diff --git a/src/atn_config_set.rs b/src/atn_config_set.rs index c44bcc0..d939509 100644 --- a/src/atn_config_set.rs +++ b/src/atn_config_set.rs @@ -130,9 +130,7 @@ impl ATNConfigSet { } pub fn add_cached( - &mut self, - config: Box, - mut merge_cache: Option<&mut MergeCache>, + &mut self, config: Box, mut merge_cache: Option<&mut MergeCache>, ) -> bool { assert!(!self.read_only); diff --git a/src/atn_deserializer.rs b/src/atn_deserializer.rs index 593da83..17bc003 100644 --- a/src/atn_deserializer.rs +++ b/src/atn_deserializer.rs @@ -241,10 +241,7 @@ impl ATNDeserializer { } fn read_sets>( - &self, - _atn: &mut ATN, - data: &mut T, - read_unicode: fn(&mut T) -> isize, + &self, _atn: &mut ATN, data: &mut T, read_unicode: fn(&mut T) -> isize, ) -> Vec { let nsets = data.next().unwrap(); let mut sets = Vec::new(); @@ -268,10 +265,7 @@ impl ATNDeserializer { } fn read_edges( - &self, - atn: &mut ATN, - data: &mut dyn Iterator, - sets: &Vec, + &self, atn: &mut ATN, data: &mut dyn Iterator, sets: &Vec, ) { let nedges = data.next().unwrap(); @@ -450,15 +444,8 @@ impl ATNDeserializer { // fn check_condition(&self, _condition: bool, _message: String) { unimplemented!() } fn edge_factory( - &self, - _atn: &ATN, - type_index: isize, - _src: ATNStateRef, - target: ATNStateRef, - arg1: isize, - arg2: isize, - arg3: isize, - sets: &Vec, + &self, _atn: &ATN, type_index: isize, _src: ATNStateRef, target: ATNStateRef, arg1: isize, + arg2: isize, arg3: isize, sets: &Vec, ) -> Box { // // let target = atn.states.get // let mut base = BaseTransition { @@ -526,10 +513,7 @@ impl ATNDeserializer { } fn state_factory( - &self, - type_index: isize, - rule_index: isize, - state_number: usize, + &self, type_index: isize, rule_index: isize, state_number: usize, ) -> Box { let mut state = BaseATNState::new_base_atnstate(); state.state_number = state_number; diff --git a/src/atn_simulator.rs b/src/atn_simulator.rs index 87d79ad..9b0bd7d 100644 --- a/src/atn_simulator.rs +++ b/src/atn_simulator.rs @@ -27,8 +27,7 @@ impl Debug for BaseATNSimulator { impl BaseATNSimulator { pub fn new_base_atnsimulator( - atn: Arc, - decision_to_dfa: Arc>>, + atn: Arc, decision_to_dfa: Arc>>, shared_context_cache: Arc, ) -> BaseATNSimulator { BaseATNSimulator { diff --git a/src/common_token_stream.rs b/src/common_token_stream.rs index 545fee4..1f5ea26 100644 --- a/src/common_token_stream.rs +++ b/src/common_token_stream.rs @@ -186,8 +186,7 @@ impl<'input, T: TokenSource<'input>> CommonTokenStream<'input, T> { // fn adjust_seek_index(&self, i: isize) -> int { unimplemented!() } fn lb( - &mut self, - k: isize, + &mut self, k: isize, ) -> Option<&<>::TF as TokenFactory<'input>>::Tok> { if k == 0 || (self.base.p - k) < 0 { return None; diff --git a/src/dfa_serializer.rs b/src/dfa_serializer.rs index dea3a62..c4cbc82 100644 --- a/src/dfa_serializer.rs +++ b/src/dfa_serializer.rs @@ -31,8 +31,7 @@ impl Display for DFASerializer<'_, '_> { impl DFASerializer<'_, '_> { pub fn new<'a, 'b>( - dfa: &'a DFA, - get_edge_label: &'b dyn Fn(usize) -> String, + dfa: &'a DFA, get_edge_label: &'b dyn Fn(usize) -> String, ) -> DFASerializer<'a, 'b> { DFASerializer { dfa, diff --git a/src/error_listener.rs b/src/error_listener.rs index 679b25d..2be1ab3 100644 --- a/src/error_listener.rs +++ b/src/error_listener.rs @@ -25,53 +25,32 @@ pub trait ErrorListener<'a, T: Recognizer<'a>> { /// in-line, without returning from the surrounding rule (via the single /// token insertion and deletion mechanism) fn syntax_error( - &self, - _recognizer: &T, - _offending_symbol: Option<&>::Inner>, - _line: isize, - _column: isize, - _msg: &str, - _error: Option<&ANTLRError>, + &self, _recognizer: &T, _offending_symbol: Option<&>::Inner>, + _line: isize, _column: isize, _msg: &str, _error: Option<&ANTLRError>, ) { } /// This method is called by the parser when a full-context prediction /// results in an ambiguity. fn report_ambiguity( - &self, - _recognizer: &T, - _dfa: &DFA, - _start_index: isize, - _stop_index: isize, - _exact: bool, - _ambig_alts: &BitSet, - _configs: &ATNConfigSet, + &self, _recognizer: &T, _dfa: &DFA, _start_index: isize, _stop_index: isize, _exact: bool, + _ambig_alts: &BitSet, _configs: &ATNConfigSet, ) { } /// This method is called when an SLL conflict occurs and the parser is about /// to use the full context information to make an LL decision. fn report_attempting_full_context( - &self, - _recognizer: &T, - _dfa: &DFA, - _start_index: isize, - _stop_index: isize, - _conflicting_alts: &BitSet, - _configs: &ATNConfigSet, + &self, _recognizer: &T, _dfa: &DFA, _start_index: isize, _stop_index: isize, + _conflicting_alts: &BitSet, _configs: &ATNConfigSet, ) { } /// This method is called by the parser when a full-context prediction has a /// unique result. fn report_context_sensitivity( - &self, - _recognizer: &T, - _dfa: &DFA, - _start_index: isize, - _stop_index: isize, - _prediction: isize, - _configs: &ATNConfigSet, + &self, _recognizer: &T, _dfa: &DFA, _start_index: isize, _stop_index: isize, + _prediction: isize, _configs: &ATNConfigSet, ) { } } @@ -82,13 +61,8 @@ pub struct ConsoleErrorListener {} impl<'a, T: Recognizer<'a>> ErrorListener<'a, T> for ConsoleErrorListener { fn syntax_error( - &self, - _recognizer: &T, - _offending_symbol: Option<&>::Inner>, - line: isize, - column: isize, - msg: &str, - _e: Option<&ANTLRError>, + &self, _recognizer: &T, _offending_symbol: Option<&>::Inner>, + line: isize, column: isize, msg: &str, _e: Option<&ANTLRError>, ) { eprintln!("line {}:{} {}", line, column, msg); } @@ -101,13 +75,8 @@ pub(crate) struct ProxyErrorListener<'b, 'a, T> { impl<'b, 'a, T: Recognizer<'a>> ErrorListener<'a, T> for ProxyErrorListener<'b, 'a, T> { fn syntax_error( - &self, - _recognizer: &T, - offending_symbol: Option<&>::Inner>, - line: isize, - column: isize, - msg: &str, - e: Option<&ANTLRError>, + &self, _recognizer: &T, offending_symbol: Option<&>::Inner>, + line: isize, column: isize, msg: &str, e: Option<&ANTLRError>, ) { for listener in self.delegates.deref() { listener.syntax_error(_recognizer, offending_symbol, line, column, msg, e) @@ -115,14 +84,8 @@ impl<'b, 'a, T: Recognizer<'a>> ErrorListener<'a, T> for ProxyErrorListener<'b, } fn report_ambiguity( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - exact: bool, - ambig_alts: &BitSet, - configs: &ATNConfigSet, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, exact: bool, + ambig_alts: &BitSet, configs: &ATNConfigSet, ) { for listener in self.delegates.deref() { listener.report_ambiguity( @@ -138,13 +101,8 @@ impl<'b, 'a, T: Recognizer<'a>> ErrorListener<'a, T> for ProxyErrorListener<'b, } fn report_attempting_full_context( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - conflicting_alts: &BitSet, - configs: &ATNConfigSet, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, + conflicting_alts: &BitSet, configs: &ATNConfigSet, ) { for listener in self.delegates.deref() { listener.report_attempting_full_context( @@ -159,12 +117,7 @@ impl<'b, 'a, T: Recognizer<'a>> ErrorListener<'a, T> for ProxyErrorListener<'b, } fn report_context_sensitivity( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - prediction: isize, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, prediction: isize, configs: &ATNConfigSet, ) { for listener in self.delegates.deref() { @@ -219,9 +172,7 @@ impl DiagnosticErrorListener { /// configuration set, if that information was not already provided by the /// parser in `alts`. pub fn get_conflicting_alts<'a>( - &self, - alts: Option<&'a BitSet>, - _configs: &ATNConfigSet, + &self, alts: Option<&'a BitSet>, _configs: &ATNConfigSet, ) -> Cow<'a, BitSet> { match alts { Some(alts) => Cow::Borrowed(alts), @@ -238,14 +189,8 @@ impl DiagnosticErrorListener { impl<'a, T: Parser<'a>> ErrorListener<'a, T> for DiagnosticErrorListener { fn report_ambiguity( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - exact: bool, - ambig_alts: &BitSet, - _configs: &ATNConfigSet, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, exact: bool, + ambig_alts: &BitSet, _configs: &ATNConfigSet, ) { if self.exact_only && !exact { return; @@ -262,13 +207,8 @@ impl<'a, T: Parser<'a>> ErrorListener<'a, T> for DiagnosticErrorListener { } fn report_attempting_full_context( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - _conflicting_alts: &BitSet, - _configs: &ATNConfigSet, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, + _conflicting_alts: &BitSet, _configs: &ATNConfigSet, ) { let msg = format!( "reportAttemptingFullContext d={}, input='{}'", @@ -281,13 +221,8 @@ impl<'a, T: Parser<'a>> ErrorListener<'a, T> for DiagnosticErrorListener { } fn report_context_sensitivity( - &self, - recognizer: &T, - dfa: &DFA, - start_index: isize, - stop_index: isize, - _prediction: isize, - _configs: &ATNConfigSet, + &self, recognizer: &T, dfa: &DFA, start_index: isize, stop_index: isize, + _prediction: isize, _configs: &ATNConfigSet, ) { let msg = format!( "reportContextSensitivity d={}, input='{}'", diff --git a/src/error_strategy.rs b/src/error_strategy.rs index ab3449a..6614cef 100644 --- a/src/error_strategy.rs +++ b/src/error_strategy.rs @@ -52,8 +52,7 @@ pub trait ErrorStrategy<'a, T: Parser<'a>>: Tid<'a> { /// /// Returns `ANTLRError` if can't recover from unexpected input symbol fn recover_inline( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) -> Result<>::Tok, ANTLRError>; /// This method is called to recover from error `e`. This method is @@ -103,8 +102,7 @@ impl<'a, T: Parser<'a> + TidAble<'a>> ErrorStrategy<'a, T> for Box Result<>::Tok, ANTLRError> { self.deref_mut().recover_inline(recognizer) } @@ -161,15 +159,13 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn begin_error_condition>( - &mut self, - _recognizer: &T, + &mut self, _recognizer: &T, ) { self.error_recovery_mode = true; } fn end_error_condition>( - &mut self, - _recognizer: &T, + &mut self, _recognizer: &T, ) { self.error_recovery_mode = false; self.last_error_index = -1; @@ -177,9 +173,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn report_no_viable_alternative>( - &self, - recognizer: &mut T, - e: &NoViableAltError, + &self, recognizer: &mut T, e: &NoViableAltError, ) -> String { let input = if e.start_token.token_type == TOKEN_EOF { "".to_owned() @@ -194,9 +188,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn report_input_mismatch>( - &self, - recognizer: &T, - e: &InputMisMatchError, + &self, recognizer: &T, e: &InputMisMatchError, ) -> String { format!( "mismatched input {} expecting {}", @@ -208,9 +200,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn report_failed_predicate>( - &self, - recognizer: &T, - e: &FailedPredicateError, + &self, recognizer: &T, e: &FailedPredicateError, ) -> String { format!( "rule {} {}", @@ -220,8 +210,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn report_unwanted_token>( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) { if self.in_error_recovery_mode(recognizer) { return; @@ -238,8 +227,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn report_missing_token>( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) { if self.in_error_recovery_mode(recognizer) { return; @@ -260,8 +248,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn single_token_insertion>( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) -> bool { let current_token = recognizer.get_input_stream_mut().la(1); @@ -284,8 +271,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn single_token_deletion<'a, T: Parser<'input, Node = Ctx, TF = Ctx::TF>>( - &mut self, - recognizer: &'a mut T, + &mut self, recognizer: &'a mut T, ) -> Option<&'a >::Tok> { let next_token_type = recognizer.get_input_stream_mut().la(2); let expecting = self.get_expected_tokens(recognizer); @@ -301,8 +287,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn get_missing_symbol>( - &self, - recognizer: &mut T, + &self, recognizer: &mut T, ) -> >::Tok { let expected = self.get_expected_tokens(recognizer); let expected_token_type = expected.get_min().unwrap_or(TOKEN_INVALID_TYPE); @@ -339,8 +324,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn get_expected_tokens>( - &self, - recognizer: &T, + &self, recognizer: &T, ) -> IntervalSet { recognizer.get_expected_tokens() } @@ -355,8 +339,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn get_error_recovery_set>( - &self, - recognizer: &T, + &self, recognizer: &T, ) -> IntervalSet { let atn = recognizer.get_interpreter().atn(); let mut ctx = Some(recognizer.get_parser_rule_context().clone()); @@ -378,9 +361,7 @@ impl<'input, Ctx: ParserNodeType<'input>> DefaultErrorStrategy<'input, Ctx> { } fn consume_until>( - &mut self, - recognizer: &mut T, - set: &IntervalSet, + &mut self, recognizer: &mut T, set: &IntervalSet, ) { let mut ttype = recognizer.get_input_stream_mut().la(1); while ttype != TOKEN_EOF && !set.contains(ttype) { @@ -394,8 +375,7 @@ impl<'a, T: Parser<'a>> ErrorStrategy<'a, T> for DefaultErrorStrategy<'a, T::Nod fn reset(&mut self, recognizer: &mut T) { self.end_error_condition(recognizer) } fn recover_inline( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) -> Result<>::Tok, ANTLRError> { let t = self .single_token_deletion(recognizer) @@ -555,9 +535,7 @@ impl<'input, Ctx: ParserNodeType<'input>> BailErrorStrategy<'input, Ctx> { pub fn new() -> Self { Self(DefaultErrorStrategy::new()) } fn process_error>( - &self, - recognizer: &mut T, - e: &ANTLRError, + &self, recognizer: &mut T, e: &ANTLRError, ) -> ANTLRError { let mut ctx = recognizer.get_parser_rule_context().clone(); let _: Option<()> = try { @@ -591,8 +569,7 @@ impl<'a, T: Parser<'a>> ErrorStrategy<'a, T> for BailErrorStrategy<'a, T::Node> #[cold] fn recover_inline( - &mut self, - recognizer: &mut T, + &mut self, recognizer: &mut T, ) -> Result<>::Tok, ANTLRError> { let err = ANTLRError::InputMismatchError(InputMisMatchError::new(recognizer)); diff --git a/src/errors.rs b/src/errors.rs index 9f0b05d..4db7709 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -167,9 +167,7 @@ impl NoViableAltError { } } pub fn new_full<'a, T: Parser<'a>>( - recog: &mut T, - start_token: OwningToken, - offending_token: OwningToken, + recog: &mut T, start_token: OwningToken, offending_token: OwningToken, ) -> NoViableAltError { Self { base: BaseRecognitionError { @@ -200,9 +198,7 @@ impl InputMisMatchError { } pub fn with_state<'a, T: Parser<'a>>( - recognizer: &mut T, - offending_state: isize, - ctx: Rc<>::Type>, + recognizer: &mut T, offending_state: isize, ctx: Rc<>::Type>, ) -> InputMisMatchError { let mut a = Self::new(recognizer); // a.base.ctx = ctx; @@ -227,9 +223,7 @@ pub struct FailedPredicateError { #[allow(missing_docs)] impl FailedPredicateError { pub fn new<'a, T: Parser<'a>>( - recog: &mut T, - predicate: Option, - msg: Option, + recog: &mut T, predicate: Option, msg: Option, ) -> ANTLRError { let tr = recog.get_interpreter().atn().states[recog.get_state() as usize] .get_transitions() diff --git a/src/lexer.rs b/src/lexer.rs index 0ebe081..2eda466 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -144,19 +144,15 @@ where type Node = EmptyContextType<'input, TF>; fn sempred( - &mut self, - _localctx: Option<&>::Type>, - rule_index: isize, - action_index: isize, + &mut self, _localctx: Option<&>::Type>, + rule_index: isize, action_index: isize, ) -> bool { >::sempred(_localctx, rule_index, action_index, self) } fn action( - &mut self, - _localctx: Option<&>::Type>, - rule_index: isize, - action_index: isize, + &mut self, _localctx: Option<&>::Type>, + rule_index: isize, action_index: isize, ) { >::action(_localctx, rule_index, action_index, self) } @@ -258,10 +254,7 @@ where /// Creates new lexer instance pub fn new_base_lexer( - input: Input, - interpreter: LexerATNSimulator, - recog: T, - factory: &'input TF, + input: Input, interpreter: LexerATNSimulator, recog: T, factory: &'input TF, ) -> Self { let mut lexer = Self { interpreter: Some(Box::new(interpreter)), @@ -404,8 +397,7 @@ where #[inline(never)] fn notify_listeners<'input, T, Input, TF>( liseners: &mut Vec>>>, - e: &ANTLRError, - lexer: &BaseLexer<'input, T, Input, TF>, + e: &ANTLRError, lexer: &BaseLexer<'input, T, Input, TF>, ) where T: LexerRecog<'input, BaseLexer<'input, T, Input, TF>> + 'static, Input: CharStream, diff --git a/src/lexer_action_executor.rs b/src/lexer_action_executor.rs index 17a7d04..7e1ed19 100644 --- a/src/lexer_action_executor.rs +++ b/src/lexer_action_executor.rs @@ -34,8 +34,7 @@ impl LexerActionExecutor { } pub(crate) fn new_copy_append( - old: Option<&Self>, - lexer_action: LexerAction, + old: Option<&Self>, lexer_action: LexerAction, ) -> LexerActionExecutor { let mut new = old .cloned() diff --git a/src/lexer_atn_simulator.rs b/src/lexer_atn_simulator.rs index 4394bc3..2f69f60 100644 --- a/src/lexer_atn_simulator.rs +++ b/src/lexer_atn_simulator.rs @@ -39,9 +39,7 @@ pub const ERROR_DFA_STATE_REF: DFAStateRef = usize::MAX; pub trait ILexerATNSimulator: IATNSimulator { fn reset(&mut self); fn match_token<'input>( - &mut self, - mode: usize, - lexer: &mut impl Lexer<'input>, + &mut self, mode: usize, lexer: &mut impl Lexer<'input>, ) -> Result; fn get_char_position_in_line(&self) -> isize; fn set_char_position_in_line(&mut self, column: isize); @@ -145,8 +143,7 @@ impl LexerATNSimulator { /// /// Called from generated parser. pub fn new_lexer_atnsimulator( - atn: Arc, - decision_to_dfa: Arc>>, + atn: Arc, decision_to_dfa: Arc>>, shared_context_cache: Arc, ) -> LexerATNSimulator { LexerATNSimulator { @@ -172,9 +169,7 @@ impl LexerATNSimulator { #[cold] fn match_atn<'input>( - &mut self, - lexer: &mut impl Lexer<'input>, - dfa: RwLockUpgradableReadGuard<'_, DFA>, + &mut self, lexer: &mut impl Lexer<'input>, dfa: RwLockUpgradableReadGuard<'_, DFA>, ) -> Result { // let start_state = self.atn().mode_to_start_state.get(self.mode as usize).ok_or(ANTLRError::IllegalStateError("invalid mode".into()))?; let atn = self.atn(); @@ -263,10 +258,7 @@ impl LexerATNSimulator { #[cold] fn compute_target_state<'input>( - &self, - dfa: &mut Option>, - s: DFAStateRef, - _t: isize, + &self, dfa: &mut Option>, s: DFAStateRef, _t: isize, lexer: &mut impl Lexer<'input>, ) -> DFAStateRef { let mut reach = ATNConfigSet::new_ordered(); @@ -356,9 +348,7 @@ impl LexerATNSimulator { // } fn fail_or_accept<'input>( - &mut self, - _t: isize, - lexer: &mut impl Lexer<'input>, + &mut self, _t: isize, lexer: &mut impl Lexer<'input>, dfa: RwLockUpgradableReadGuard<'_, DFA>, ) -> Result { // println!("fail_or_accept"); @@ -399,9 +389,7 @@ impl LexerATNSimulator { } fn compute_start_state<'input>( - &self, - _p: &dyn ATNState, - lexer: &mut impl Lexer<'input>, + &self, _p: &dyn ATNState, lexer: &mut impl Lexer<'input>, ) -> Box { // let initial_context = &EMPTY_PREDICTION_CONTEXT; let mut config_set = ATNConfigSet::new_ordered(); @@ -614,10 +602,7 @@ impl LexerATNSimulator { } fn capture_sim_state( - &mut self, - dfa: &DFA, - input: &impl IntStream, - dfa_state: DFAStateRef, + &mut self, dfa: &DFA, input: &impl IntStream, dfa_state: DFAStateRef, ) -> bool { if dfa.states[dfa_state].is_accept_state { self.prev_accept = SimState { diff --git a/src/ll1_analyzer.rs b/src/ll1_analyzer.rs index 44a4aa3..89082bb 100644 --- a/src/ll1_analyzer.rs +++ b/src/ll1_analyzer.rs @@ -25,10 +25,7 @@ impl LL1Analyzer<'_> { // fn get_decision_lookahead(&self, _s: &dyn ATNState) -> &Vec { unimplemented!() } pub fn look<'input, Ctx: ParserNodeType<'input>>( - &self, - s: &dyn ATNState, - stop_state: Option<&dyn ATNState>, - ctx: Option<&Ctx::Type>, + &self, s: &dyn ATNState, stop_state: Option<&dyn ATNState>, ctx: Option<&Ctx::Type>, ) -> IntervalSet { let mut r = IntervalSet::new(); let look_ctx = ctx.map(|x| PredictionContext::from_rule_context::(self.atn, x)); diff --git a/src/parser.rs b/src/parser.rs index e3c3caf..0a72185 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -38,9 +38,7 @@ pub trait Parser<'input>: Recognizer<'input> { //fn sempred(&mut self, _localctx: Option<&dyn ParserRuleContext>, rule_index: isize, action_index: isize) -> bool { true } fn precpred( - &self, - localctx: Option<&>::Type>, - precedence: isize, + &self, localctx: Option<&>::Type>, precedence: isize, ) -> bool; // fn get_error_handler(&self) -> ErrorStrategy; @@ -55,10 +53,7 @@ pub trait Parser<'input>: Recognizer<'input> { Self: Sized; fn remove_error_listeners(&mut self); fn notify_error_listeners( - &self, - msg: String, - offending_token: Option, - err: Option<&ANTLRError>, + &self, msg: String, offending_token: Option, err: Option<&ANTLRError>, ); fn get_error_lister_dispatch<'a>(&'a self) -> Box + 'a> where @@ -188,10 +183,7 @@ where type Node = Ctx; fn sempred( - &mut self, - localctx: Option<&Ctx::Type>, - rule_index: isize, - action_index: isize, + &mut self, localctx: Option<&Ctx::Type>, rule_index: isize, action_index: isize, ) -> bool { >::sempred(localctx, rule_index, action_index, self) } @@ -296,10 +288,7 @@ where fn remove_error_listeners(&mut self) { self.error_listeners.borrow_mut().clear(); } fn notify_error_listeners( - &self, - msg: String, - offending_token: Option, - err: Option<&ANTLRError>, + &self, msg: String, offending_token: Option, err: Option<&ANTLRError>, ) { self._syntax_errors.update(|it| it + 1); let offending_token: Option<&_> = match offending_token { @@ -384,9 +373,7 @@ where #[inline] pub fn match_token( - &mut self, - ttype: isize, - err_handler: &mut impl ErrorStrategy<'input, Self>, + &mut self, ttype: isize, err_handler: &mut impl ErrorStrategy<'input, Self>, ) -> Result<>::Tok, ANTLRError> { let mut token = self.get_current_token().clone(); if token.borrow().get_token_type() == ttype { @@ -410,8 +397,7 @@ where #[inline] pub fn match_wildcard( - &mut self, - err_handler: &mut impl ErrorStrategy<'input, Self>, + &mut self, err_handler: &mut impl ErrorStrategy<'input, Self>, ) -> Result<>::Tok, ANTLRError> { let mut t = self.get_current_token().clone(); if t.borrow().get_token_type() > 0 { @@ -549,11 +535,7 @@ where } pub fn enter_recursion_rule( - &mut self, - localctx: Rc, - state: isize, - _rule_index: usize, - precedence: isize, + &mut self, localctx: Rc, state: isize, _rule_index: usize, precedence: isize, ) { self.set_state(state); self.precedence_stack.push(precedence); @@ -563,10 +545,7 @@ where } pub fn push_new_recursion_context( - &mut self, - localctx: Rc, - state: isize, - _rule_index: usize, + &mut self, localctx: Rc, state: isize, _rule_index: usize, ) { let prev = self.ctx.take().unwrap(); prev.set_parent(&Some(localctx.clone())); @@ -608,15 +587,13 @@ where } fn create_token_node( - &self, - token: >::Tok, + &self, token: >::Tok, ) -> Rc> { TerminalNode::new(token).into() } fn create_error_node( - &self, - token: >::Tok, + &self, token: >::Tok, ) -> Rc> { ErrorNode::new(token).into() } diff --git a/src/parser_atn_simulator.rs b/src/parser_atn_simulator.rs index 8b3699c..7a397c4 100644 --- a/src/parser_atn_simulator.rs +++ b/src/parser_atn_simulator.rs @@ -127,8 +127,7 @@ pub(crate) type MergeCache = HashMap< impl ParserATNSimulator { /// creates new `ParserATNSimulator` pub fn new( - atn: Arc, - decision_to_dfa: Arc>>, + atn: Arc, decision_to_dfa: Arc>>, shared_context_cache: Arc, ) -> ParserATNSimulator { ParserATNSimulator { @@ -152,9 +151,7 @@ impl ParserATNSimulator { /// Called by generated parser to choose an alternative when LL(1) parsing is not enough pub fn adaptive_predict<'a, T: Parser<'a>>( - &self, - decision: isize, - parser: &mut T, + &self, decision: isize, parser: &mut T, ) -> Result { self.start_index.set(parser.get_input_stream_mut().index()); let mut merge_cache: MergeCache = HashMap::with_hasher(MurmurHasherBuilder {}); @@ -229,9 +226,7 @@ impl ParserATNSimulator { #[allow(non_snake_case)] fn exec_atn<'a, T: Parser<'a>>( - &self, - local: &mut Local<'_, 'a, T>, - s0: DFAStateRef, + &self, local: &mut Local<'_, 'a, T>, s0: DFAStateRef, ) -> Result { let mut previousD = s0; @@ -351,9 +346,7 @@ impl ParserATNSimulator { #[allow(non_snake_case)] fn get_existing_target_state( - dfa: &DFA, - previousD: DFAStateRef, - t: isize, + dfa: &DFA, previousD: DFAStateRef, t: isize, ) -> Option { dfa.states[previousD] .edges @@ -531,11 +524,7 @@ impl ParserATNSimulator { // ATNConfigSet is pretty big so should be boxed to move it cheaper fn compute_reach_set<'a, T: Parser<'a>>( - &self, - closure: &ATNConfigSet, - t: isize, - full_ctx: bool, - local: &mut Local<'_, 'a, T>, + &self, closure: &ATNConfigSet, t: isize, full_ctx: bool, local: &mut Local<'_, 'a, T>, ) -> Option { // println!("in computeReachSet, starting closure: {:?}",closure); let mut intermediate = ATNConfigSet::new_base_atnconfig_set(full_ctx); @@ -633,10 +622,7 @@ impl ParserATNSimulator { } fn remove_all_configs_not_in_rule_stop_state( - &self, - configs: ATNConfigSet, - look_to_end_of_rule: bool, - merge_cache: &mut MergeCache, + &self, configs: ATNConfigSet, look_to_end_of_rule: bool, merge_cache: &mut MergeCache, ) -> ATNConfigSet { if self.all_configs_in_rule_stop_state(&configs) { return configs; @@ -669,10 +655,7 @@ impl ParserATNSimulator { } fn compute_start_state<'a, T: Parser<'a>>( - &self, - a: ATNStateRef, - initial_ctx: Arc, - full_ctx: bool, + &self, a: ATNStateRef, initial_ctx: Arc, full_ctx: bool, local: &mut Local<'_, 'a, T>, ) -> ATNConfigSet { // let initial_ctx = PredictionContext::prediction_context_from_rule_context(self.atn(),ctx); @@ -705,9 +688,7 @@ impl ParserATNSimulator { } fn apply_precedence_filter<'a, T: Parser<'a>>( - &self, - configs: &ATNConfigSet, - local: &mut Local<'_, 'a, T>, + &self, configs: &ATNConfigSet, local: &mut Local<'_, 'a, T>, ) -> ATNConfigSet { //println!("apply_precedence_filter"); let mut states_from_alt1 = HashMap::new(); @@ -766,10 +747,7 @@ impl ParserATNSimulator { } fn get_preds_for_ambig_alts( - &self, - ambig_alts: &BitSet, - configs: &ATNConfigSet, - nalts: usize, + &self, ambig_alts: &BitSet, configs: &ATNConfigSet, nalts: usize, ) -> Option> { let mut alt_to_pred = Vec::with_capacity(nalts + 1); alt_to_pred.resize_with(nalts + 1, || None); @@ -806,9 +784,7 @@ impl ParserATNSimulator { } fn get_predicate_predictions( - &self, - ambig_alts: &BitSet, - alt_to_pred: Vec, + &self, ambig_alts: &BitSet, alt_to_pred: Vec, ) -> Vec { let mut pairs = vec![]; let mut contains_predicate = false; @@ -832,9 +808,7 @@ impl ParserATNSimulator { } fn get_syn_valid_or_sem_invalid_alt_that_finished_decision_entry_rule<'a, T: Parser<'a>>( - &self, - configs: &ATNConfigSet, - local: &mut Local<'_, 'a, T>, + &self, configs: &ATNConfigSet, local: &mut Local<'_, 'a, T>, ) -> isize { let (sem_valid_configs, sem_invalid_configs) = self.split_according_to_semantic_validity(configs, local); @@ -855,9 +829,7 @@ impl ParserATNSimulator { } fn split_according_to_semantic_validity<'a, T: Parser<'a>>( - &self, - configs: &ATNConfigSet, - local: &mut Local<'_, 'a, T>, + &self, configs: &ATNConfigSet, local: &mut Local<'_, 'a, T>, ) -> (ATNConfigSet, ATNConfigSet) { let mut succeeded = ATNConfigSet::new_base_atnconfig_set(configs.full_context()); let mut failed = ATNConfigSet::new_base_atnconfig_set(configs.full_context()); @@ -896,10 +868,7 @@ impl ParserATNSimulator { } fn eval_semantic_context<'a, T: Parser<'a>>( - &self, - local: &mut Local<'_, 'a, T>, - pred_predictions: &Vec, - complete: bool, + &self, local: &mut Local<'_, 'a, T>, pred_predictions: &Vec, complete: bool, ) -> BitSet { let mut predictions = BitSet::new(); for pred in pred_predictions { @@ -927,24 +896,16 @@ impl ParserATNSimulator { } fn eval_predicate<'a, T: Parser<'a>>( - &self, - local: &mut Local<'_, 'a, T>, - pred: impl Borrow, - _alt: isize, + &self, local: &mut Local<'_, 'a, T>, pred: impl Borrow, _alt: isize, _full_ctx: bool, ) -> bool { pred.borrow().evaluate(local.parser, &*local.outer_context) } fn closure<'a, T: Parser<'a>>( - &self, - config: ATNConfig, - configs: &mut ATNConfigSet, - closure_busy: &mut HashSet, - collect_predicates: bool, - full_ctx: bool, - treat_eofas_epsilon: bool, - local: &mut Local<'_, 'a, T>, + &self, config: ATNConfig, configs: &mut ATNConfigSet, + closure_busy: &mut HashSet, collect_predicates: bool, full_ctx: bool, + treat_eofas_epsilon: bool, local: &mut Local<'_, 'a, T>, ) { // println!("cl{}", config.get_state()); let initial_depth = 0; @@ -964,15 +925,9 @@ impl ParserATNSimulator { } fn closure_checking_stop_state<'a, T: Parser<'a>>( - &self, - mut config: ATNConfig, - configs: &mut ATNConfigSet, - closure_busy: &mut HashSet, - collect_predicates: bool, - full_ctx: bool, - depth: isize, - treat_eofas_epsilon: bool, - local: &mut Local<'_, 'a, T>, + &self, mut config: ATNConfig, configs: &mut ATNConfigSet, + closure_busy: &mut HashSet, collect_predicates: bool, full_ctx: bool, + depth: isize, treat_eofas_epsilon: bool, local: &mut Local<'_, 'a, T>, ) { // println!("closure({:?})",config); if let RuleStopState = self.atn().states[config.get_state()].get_state_type() { @@ -1051,15 +1006,9 @@ impl ParserATNSimulator { } fn closure_work<'a, T: Parser<'a>>( - &self, - config: ATNConfig, - configs: &mut ATNConfigSet, - closure_busy: &mut HashSet, - collect_predicates: bool, - full_ctx: bool, - depth: isize, - treat_eofas_epsilon: bool, - local: &mut Local<'_, 'a, T>, + &self, config: ATNConfig, configs: &mut ATNConfigSet, + closure_busy: &mut HashSet, collect_predicates: bool, full_ctx: bool, + depth: isize, treat_eofas_epsilon: bool, local: &mut Local<'_, 'a, T>, ) { //println!("depth {}",depth); // println!("closure_work started {:?}",config); @@ -1220,14 +1169,8 @@ impl ParserATNSimulator { // fn get_rule_name(&self, index: isize) -> String { unimplemented!() } fn get_epsilon_target<'a, T: Parser<'a>>( - &self, - config: &ATNConfig, - t: &dyn Transition, - collect_predicates: bool, - in_context: bool, - full_ctx: bool, - treat_eofas_epsilon: bool, - local: &mut Local<'_, 'a, T>, + &self, config: &ATNConfig, t: &dyn Transition, collect_predicates: bool, in_context: bool, + full_ctx: bool, treat_eofas_epsilon: bool, local: &mut Local<'_, 'a, T>, ) -> Option { match t.get_serialization_type() { TransitionType::TRANSITION_EPSILON => { @@ -1273,13 +1216,8 @@ impl ParserATNSimulator { } fn precedence_transition<'a, T: Parser<'a>>( - &self, - config: &ATNConfig, - pt: &PrecedencePredicateTransition, - collect_predicates: bool, - in_context: bool, - full_ctx: bool, - local: &mut Local<'_, 'a, T>, + &self, config: &ATNConfig, pt: &PrecedencePredicateTransition, collect_predicates: bool, + in_context: bool, full_ctx: bool, local: &mut Local<'_, 'a, T>, ) -> Option { let target = self.atn().states[pt.target].deref(); if collect_predicates && in_context { @@ -1309,13 +1247,8 @@ impl ParserATNSimulator { } fn pred_transition<'a, T: Parser<'a>>( - &self, - config: &ATNConfig, - pt: &PredicateTransition, - collect_predicates: bool, - in_context: bool, - full_ctx: bool, - local: &mut Local<'_, 'a, T>, + &self, config: &ATNConfig, pt: &PredicateTransition, collect_predicates: bool, + in_context: bool, full_ctx: bool, local: &mut Local<'_, 'a, T>, ) -> Option { let target = self.atn().states[pt.target].deref(); if collect_predicates && (!pt.is_ctx_dependent || (pt.is_ctx_dependent && in_context)) { @@ -1376,10 +1309,7 @@ impl ParserATNSimulator { // fn dump_dead_end_configs(&self, nvae: * NoViableAltError) { unimplemented!() } // fn no_viable_alt<'a, T: Parser<'a>>( - &self, - local: &mut Local<'_, 'a, T>, - _configs: &ATNConfigSet, - start_index: isize, + &self, local: &mut Local<'_, 'a, T>, _configs: &ATNConfigSet, start_index: isize, ) -> ANTLRError { let start_token = local.parser.get_input_stream().get(start_index).borrow(); let start_token = Token::to_owned(start_token); @@ -1452,13 +1382,8 @@ impl ParserATNSimulator { } fn report_attempting_full_context<'a, T: Parser<'a>>( - &self, - dfa: &DFA, - conflicting_alts: &BitSet, - configs: &ATNConfigSet, - start_index: isize, - stop_index: isize, - parser: &mut T, + &self, dfa: &DFA, conflicting_alts: &BitSet, configs: &ATNConfigSet, start_index: isize, + stop_index: isize, parser: &mut T, ) { // let ambig_index = parser.get_current_token().get_token_index(); parser @@ -1474,13 +1399,8 @@ impl ParserATNSimulator { } fn report_context_sensitivity<'a, T: Parser<'a>>( - &self, - dfa: &DFA, - prediction: isize, - configs: &ATNConfigSet, - start_index: isize, - stop_index: isize, - parser: &mut T, + &self, dfa: &DFA, prediction: isize, configs: &ATNConfigSet, start_index: isize, + stop_index: isize, parser: &mut T, ) { parser .get_error_lister_dispatch() @@ -1488,14 +1408,8 @@ impl ParserATNSimulator { } fn report_ambiguity<'a, T: Parser<'a>>( - &self, - dfa: &DFA, - start_index: isize, - stop_index: isize, - exact: bool, - ambig_alts: &BitSet, - configs: &ATNConfigSet, - parser: &mut T, + &self, dfa: &DFA, start_index: isize, stop_index: isize, exact: bool, ambig_alts: &BitSet, + configs: &ATNConfigSet, parser: &mut T, ) { parser.get_error_lister_dispatch().report_ambiguity( parser, diff --git a/src/parser_rule_context.rs b/src/parser_rule_context.rs index 4926ad8..98f0f56 100644 --- a/src/parser_rule_context.rs +++ b/src/parser_rule_context.rs @@ -425,8 +425,7 @@ impl<'input, Ctx: CustomRuleContext<'input> + TidAble<'input>> ParseTree<'input> #[allow(missing_docs)] impl<'input, Ctx: CustomRuleContext<'input> + 'input> BaseParserRuleContext<'input, Ctx> { pub fn new_parser_ctx( - parent_ctx: Option>::Type>>, - invoking_state: isize, + parent_ctx: Option>::Type>>, invoking_state: isize, ext: Ctx, ) -> Self { Self { @@ -438,8 +437,7 @@ impl<'input, Ctx: CustomRuleContext<'input> + 'input> BaseParserRuleContext<'inp } } pub fn copy_from + ?Sized>( - ctx: &T, - ext: Ctx, + ctx: &T, ext: Ctx, ) -> Self { Self { base: BaseRuleContext::new_parser_ctx( diff --git a/src/prediction_context.rs b/src/prediction_context.rs index 246eecc..d327882 100644 --- a/src/prediction_context.rs +++ b/src/prediction_context.rs @@ -147,8 +147,7 @@ lazy_static! { impl PredictionContext { pub fn new_array( - parents: Vec>>, - return_states: Vec, + parents: Vec>>, return_states: Vec, ) -> PredictionContext { PredictionContext::Array(ArrayPredictionContext { cached_hash: 0, @@ -158,8 +157,7 @@ impl PredictionContext { } pub fn new_singleton( - parent_ctx: Option>, - return_state: isize, + parent_ctx: Option>, return_state: isize, ) -> PredictionContext { PredictionContext::Singleton(SingletonPredictionContext { cached_hash: 0, @@ -354,9 +352,7 @@ impl PredictionContext { } fn merge_singletons( - a: &SingletonPredictionContext, - b: &SingletonPredictionContext, - root_is_wildcard: bool, + a: &SingletonPredictionContext, b: &SingletonPredictionContext, root_is_wildcard: bool, merge_cache: &mut Option<&mut MergeCache>, ) -> Arc { Self::merge_root(a, b, root_is_wildcard).unwrap_or_else(|| { @@ -396,9 +392,7 @@ impl PredictionContext { } fn merge_root( - a: &SingletonPredictionContext, - b: &SingletonPredictionContext, - root_is_wildcard: bool, + a: &SingletonPredictionContext, b: &SingletonPredictionContext, root_is_wildcard: bool, ) -> Option> { if root_is_wildcard { if a.is_empty() || b.is_empty() { @@ -432,10 +426,8 @@ impl PredictionContext { } fn merge_arrays( - a: Cow<'_, ArrayPredictionContext>, - b: Cow<'_, ArrayPredictionContext>, - root_is_wildcard: bool, - merge_cache: &mut Option<&mut MergeCache>, + a: Cow<'_, ArrayPredictionContext>, b: Cow<'_, ArrayPredictionContext>, + root_is_wildcard: bool, merge_cache: &mut Option<&mut MergeCache>, ) -> PredictionContext { // let a = a.deref(); // let b = b.deref(); @@ -515,8 +507,7 @@ impl PredictionContext { } pub fn from_rule_context<'input, Ctx: ParserNodeType<'input>>( - atn: &ATN, - outer_context: &Ctx::Type, + atn: &ATN, outer_context: &Ctx::Type, ) -> Arc { if outer_context.get_parent_ctx().is_none() || outer_context.is_empty() /*ptr::eq(outer_context, empty_ctx().as_ref())*/ @@ -585,8 +576,7 @@ impl PredictionContextCache { #[doc(hidden)] pub fn get_shared_context( - &self, - context: &Arc, + &self, context: &Arc, visited: &mut HashMap<*const PredictionContext, Arc>, ) -> Arc { if context.is_empty() { diff --git a/src/prediction_mode.rs b/src/prediction_mode.rs index d1f3362..e2b3c1b 100644 --- a/src/prediction_mode.rs +++ b/src/prediction_mode.rs @@ -84,8 +84,7 @@ impl PredictionMode { // // pub(crate) fn has_sll_conflict_terminating_prediction( - mode: PredictionMode, - configs: &ATNConfigSet, + mode: PredictionMode, configs: &ATNConfigSet, ) -> bool { // if all_configs_in_rule_stop_states(configs) { // return true checked outside diff --git a/src/recognizer.rs b/src/recognizer.rs index c58cb5b..c7a394f 100644 --- a/src/recognizer.rs +++ b/src/recognizer.rs @@ -24,10 +24,8 @@ pub fn check_version(major: &str, minor: &str) { pub trait Recognizer<'input>: TokenAware<'input> { type Node: ParserNodeType<'input, TF = Self::TF>; fn sempred( - &mut self, - _localctx: Option<&>::Type>, - _rule_index: isize, - _action_index: isize, + &mut self, _localctx: Option<&>::Type>, + _rule_index: isize, _action_index: isize, ) -> bool where Self: Sized, @@ -35,10 +33,8 @@ pub trait Recognizer<'input>: TokenAware<'input> { true } fn action( - &mut self, - _localctx: Option<&>::Type>, - _rule_index: isize, - _action_index: isize, + &mut self, _localctx: Option<&>::Type>, + _rule_index: isize, _action_index: isize, ) where Self: Sized, { @@ -60,19 +56,15 @@ pub trait Recognizer<'input>: TokenAware<'input> { /// Generated by ANTLR tool from actions and predicated added in grammar file pub trait Actions<'a, P: Recognizer<'a>> { fn sempred( - _localctx: Option<&>::Type>, - _rule_index: isize, - _action_index: isize, - _recog: &mut P, + _localctx: Option<&>::Type>, _rule_index: isize, + _action_index: isize, _recog: &mut P, ) -> bool { true } fn action( - _localctx: Option<&>::Type>, - _rule_index: isize, - _action_index: isize, - _recog: &mut P, + _localctx: Option<&>::Type>, _rule_index: isize, + _action_index: isize, _recog: &mut P, ) { } diff --git a/src/rule_context.rs b/src/rule_context.rs index a9ffa31..7f51393 100644 --- a/src/rule_context.rs +++ b/src/rule_context.rs @@ -126,8 +126,7 @@ pub struct BaseRuleContext<'input, ExtCtx: CustomRuleContext<'input>> { impl<'input, ExtCtx: CustomRuleContext<'input>> BaseRuleContext<'input, ExtCtx> { pub fn new_parser_ctx( parent_ctx: Option>::Type>>, - invoking_state: isize, - ext: ExtCtx, + invoking_state: isize, ext: ExtCtx, ) -> Self { Self { parent_ctx: RefCell::new(parent_ctx.as_ref().map(Rc::downgrade)), @@ -137,8 +136,7 @@ impl<'input, ExtCtx: CustomRuleContext<'input>> BaseRuleContext<'input, ExtCtx> } pub fn copy_from + ?Sized>( - ctx: &T, - ext: ExtCtx, + ctx: &T, ext: ExtCtx, ) -> Self { Self::new_parser_ctx(ctx.get_parent_ctx(), ctx.get_invoking_state(), ext) } diff --git a/src/semantic_context.rs b/src/semantic_context.rs index a32f5e9..c780d15 100644 --- a/src/semantic_context.rs +++ b/src/semantic_context.rs @@ -37,9 +37,7 @@ impl SemanticContext { is_ctx_dependent: false, }; pub(crate) fn evaluate<'a, T: Parser<'a>>( - &self, - parser: &mut T, - outer_context: &>::Type, + &self, parser: &mut T, outer_context: &>::Type, ) -> bool { match self { SemanticContext::Predicate { @@ -60,9 +58,7 @@ impl SemanticContext { } } pub(crate) fn eval_precedence<'a, 'b, T: Parser<'b>>( - &'a self, - parser: &T, - outer_context: &>::Type, + &'a self, parser: &T, outer_context: &>::Type, ) -> Option> { match self { SemanticContext::Predicate { .. } => Some(Borrowed(self)), @@ -191,8 +187,7 @@ impl SemanticContext { } pub fn and( - a: Option>, - b: Option>, + a: Option>, b: Option>, ) -> SemanticContext { match (a, b) { (None, None) => Self::NONE, @@ -213,8 +208,7 @@ impl SemanticContext { } pub fn or( - a: Option>, - b: Option>, + a: Option>, b: Option>, ) -> SemanticContext { match (a, b) { (None, None) => Self::NONE, diff --git a/src/token_factory.rs b/src/token_factory.rs index 829f9eb..3c6b555 100644 --- a/src/token_factory.rs +++ b/src/token_factory.rs @@ -56,15 +56,9 @@ pub trait TokenFactory<'a>: TidAble<'a> + Sized { /// Creates token either from `sourse` or from pure data in `text` /// Either `source` or `text` are not None fn create( - &'a self, - source: Option<&mut T>, - ttype: isize, - text: Option<::Owned>, - channel: isize, - start: isize, - stop: isize, - line: isize, - column: isize, + &'a self, source: Option<&mut T>, ttype: isize, + text: Option<::Owned>, channel: isize, start: isize, stop: isize, + line: isize, column: isize, ) -> Self::Tok where T: CharStream + ?Sized; @@ -94,15 +88,8 @@ impl<'a> TokenFactory<'a> for CommonTokenFactory { #[inline] fn create( - &'a self, - source: Option<&mut T>, - ttype: isize, - text: Option, - channel: isize, - start: isize, - stop: isize, - line: isize, - column: isize, + &'a self, source: Option<&mut T>, ttype: isize, text: Option, channel: isize, + start: isize, stop: isize, line: isize, column: isize, ) -> Self::Tok where T: CharStream + ?Sized, @@ -149,15 +136,8 @@ impl<'a> TokenFactory<'a> for OwningTokenFactory { #[inline] fn create( - &'a self, - source: Option<&mut T>, - ttype: isize, - text: Option, - channel: isize, - start: isize, - stop: isize, - line: isize, - column: isize, + &'a self, source: Option<&mut T>, ttype: isize, text: Option, channel: isize, + start: isize, stop: isize, line: isize, column: isize, ) -> Self::Tok where T: CharStream + ?Sized, @@ -261,15 +241,9 @@ where #[inline] fn create( - &'input self, - source: Option<&mut T>, - ttype: isize, - text: Option<::Owned>, - channel: isize, - start: isize, - stop: isize, - line: isize, - column: isize, + &'input self, source: Option<&mut T>, ttype: isize, + text: Option<::Owned>, channel: isize, start: isize, stop: isize, + line: isize, column: isize, ) -> Self::Tok where T: CharStream + ?Sized, diff --git a/src/tree.rs b/src/tree.rs index f4ff24d..3765139 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -73,8 +73,7 @@ pub trait ParseTree<'input>: Tree<'input> { /// (root child1 .. childN). Print just a node if this is a leaf. /// We have to know the recognizer so we can get rule names. fn to_string_tree( - &self, - r: &dyn Recognizer<'input, TF = Self::TF, Node = Self::Ctx>, + &self, r: &dyn Recognizer<'input, TF = Self::TF, Node = Self::Ctx>, ) -> String { trees::string_tree(self, r.get_rule_names()) } diff --git a/src/vocabulary.rs b/src/vocabulary.rs index b5c597b..090d0e0 100644 --- a/src/vocabulary.rs +++ b/src/vocabulary.rs @@ -34,9 +34,7 @@ fn collect_to_string<'b, T: Borrow + 'b>( impl VocabularyImpl { pub fn new<'b, T: Borrow + 'b, Iter: IntoIterator>>( - literal_names: Iter, - symbolic_names: Iter, - display_names: Option, + literal_names: Iter, symbolic_names: Iter, display_names: Option, ) -> VocabularyImpl { // let display_names = display_names.unwrap_or(&[]); VocabularyImpl { diff --git a/tests/gen/csvlexer.rs b/tests/gen/csvlexer.rs index 0dd085b..2c885b2 100644 --- a/tests/gen/csvlexer.rs +++ b/tests/gen/csvlexer.rs @@ -34,11 +34,11 @@ pub const T__2: isize = 3; pub const WS: isize = 4; pub const TEXT: isize = 5; pub const STRING: isize = 6; -pub const channelNames: [&'static str; 0 + 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; +pub const channelNames: [&str; 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; -pub const modeNames: [&'static str; 1] = ["DEFAULT_MODE"]; +pub const modeNames: [&str; 1] = ["DEFAULT_MODE"]; -pub const ruleNames: [&'static str; 6] = ["T__0", "T__1", "T__2", "WS", "TEXT", "STRING"]; +pub const ruleNames: [&str; 6] = ["T__0", "T__1", "T__2", "WS", "TEXT", "STRING"]; pub const _LITERAL_NAMES: [Option<&'static str>; 4] = [None, Some("','"), Some("'\r'"), Some("'\n'")]; @@ -167,7 +167,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x02\ \x08\x2c\x08\x01\x04\x02\x09\x02\x04\x03\x09\x03\x04\x04\x09\x04\x04\x05\ \x09\x05\x04\x06\x09\x06\x04\x07\x09\x07\x03\x02\x03\x02\x03\x03\x03\x03\ diff --git a/tests/gen/csvparser.rs b/tests/gen/csvparser.rs index 96f8dd3..c2adc5c 100644 --- a/tests/gen/csvparser.rs +++ b/tests/gen/csvparser.rs @@ -48,7 +48,7 @@ pub const RULE_csvFile: usize = 0; pub const RULE_hdr: usize = 1; pub const RULE_row: usize = 2; pub const RULE_field: usize = 3; -pub const ruleNames: [&'static str; 4] = ["csvFile", "hdr", "row", "field"]; +pub const ruleNames: [&str; 4] = ["csvFile", "hdr", "row", "field"]; pub const _LITERAL_NAMES: [Option<&'static str>; 4] = [None, Some("','"), Some("'\r'"), Some("'\n'")]; @@ -247,8 +247,7 @@ antlr_rust::type_id! {CsvFileContextExt<'a>} impl<'input> CsvFileContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -382,8 +381,7 @@ antlr_rust::type_id! {HdrContextExt<'a>} impl<'input> HdrContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -477,8 +475,7 @@ antlr_rust::type_id! {RowContextExt<'a>} impl<'input> RowContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -610,8 +607,7 @@ antlr_rust::type_id! {FieldContextExt<'a>} impl<'input> FieldContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -716,7 +712,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x03\ \x08\x25\x04\x02\x09\x02\x04\x03\x09\x03\x04\x04\x09\x04\x04\x05\x09\x05\ \x03\x02\x03\x02\x06\x02\x0d\x0a\x02\x0d\x02\x0e\x02\x0e\x03\x03\x03\x03\ diff --git a/tests/gen/labelslexer.rs b/tests/gen/labelslexer.rs index 420c41d..42c6472 100644 --- a/tests/gen/labelslexer.rs +++ b/tests/gen/labelslexer.rs @@ -37,11 +37,11 @@ pub const T__5: isize = 6; pub const ID: isize = 7; pub const INT: isize = 8; pub const WS: isize = 9; -pub const channelNames: [&'static str; 0 + 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; +pub const channelNames: [&str; 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; -pub const modeNames: [&'static str; 1] = ["DEFAULT_MODE"]; +pub const modeNames: [&str; 1] = ["DEFAULT_MODE"]; -pub const ruleNames: [&'static str; 9] = [ +pub const ruleNames: [&str; 9] = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "ID", "INT", "WS", ]; @@ -184,7 +184,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x02\ \x0b\x31\x08\x01\x04\x02\x09\x02\x04\x03\x09\x03\x04\x04\x09\x04\x04\x05\ \x09\x05\x04\x06\x09\x06\x04\x07\x09\x07\x04\x08\x09\x08\x04\x09\x09\x09\ diff --git a/tests/gen/labelsparser.rs b/tests/gen/labelsparser.rs index a470331..fb247b5 100644 --- a/tests/gen/labelsparser.rs +++ b/tests/gen/labelsparser.rs @@ -47,7 +47,7 @@ pub const INT: isize = 8; pub const WS: isize = 9; pub const RULE_s: usize = 0; pub const RULE_e: usize = 1; -pub const ruleNames: [&'static str; 2] = ["s", "e"]; +pub const ruleNames: [&str; 2] = ["s", "e"]; pub const _LITERAL_NAMES: [Option<&'static str>; 7] = [ None, @@ -213,10 +213,8 @@ impl<'input, I: TokenStream<'input, TF = LocalTokenFactory<'input>> + TidAble<'i fn get_vocabulary(&self) -> &dyn Vocabulary { &**VOCABULARY } fn sempred( - _localctx: Option<&(dyn LabelsParserContext<'input> + 'input)>, - rule_index: isize, - pred_index: isize, - recog: &mut BaseParserType<'input, I>, + _localctx: Option<&(dyn LabelsParserContext<'input> + 'input)>, rule_index: isize, + pred_index: isize, recog: &mut BaseParserType<'input, I>, ) -> bool { match rule_index { 1 => LabelsParser::<'input, I, _>::e_sempred( @@ -234,8 +232,7 @@ where I: TokenStream<'input, TF = LocalTokenFactory<'input>> + TidAble<'input>, { fn e_sempred( - _localctx: Option<&EContext<'input>>, - pred_index: isize, + _localctx: Option<&EContext<'input>>, pred_index: isize, recog: &mut ::Target, ) -> bool { match pred_index { @@ -277,8 +274,7 @@ antlr_rust::type_id! {SContextExt<'a>} impl<'input> SContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -402,8 +398,7 @@ antlr_rust::type_id! {EContextExt<'a>} impl<'input> EContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(EContextAll::Error(BaseParserRuleContext::new_parser_ctx( parent, @@ -924,8 +919,7 @@ where "null" } .to_owned() - } - .to_owned(); + }; if let EContextAll::AnIntContext(ctx) = cast_mut::<_, EContextAll>(&mut _localctx) { @@ -1012,8 +1006,7 @@ where "null" } .to_owned() - } - .to_owned(); + }; if let EContextAll::AnIDContext(ctx) = cast_mut::<_, EContextAll>(&mut _localctx) { @@ -1354,7 +1347,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x03\ \x0b\x2a\x04\x02\x09\x02\x04\x03\x09\x03\x03\x02\x03\x02\x03\x03\x03\x03\ \x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x03\x05\x03\ diff --git a/tests/gen/referencetoatnlexer.rs b/tests/gen/referencetoatnlexer.rs index 8739255..9cebee9 100644 --- a/tests/gen/referencetoatnlexer.rs +++ b/tests/gen/referencetoatnlexer.rs @@ -31,11 +31,11 @@ use std::sync::Arc; pub const ID: isize = 1; pub const ATN: isize = 2; pub const WS: isize = 3; -pub const channelNames: [&'static str; 0 + 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; +pub const channelNames: [&str; 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; -pub const modeNames: [&'static str; 1] = ["DEFAULT_MODE"]; +pub const modeNames: [&str; 1] = ["DEFAULT_MODE"]; -pub const ruleNames: [&'static str; 3] = ["ID", "ATN", "WS"]; +pub const ruleNames: [&str; 3] = ["ID", "ATN", "WS"]; pub const _LITERAL_NAMES: [Option<&'static str>; 0] = []; pub const _SYMBOLIC_NAMES: [Option<&'static str>; 4] = [None, Some("ID"), Some("ATN"), Some("WS")]; @@ -162,7 +162,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x02\ \x05\x17\x08\x01\x04\x02\x09\x02\x04\x03\x09\x03\x04\x04\x09\x04\x03\x02\ \x06\x02\x0b\x0a\x02\x0d\x02\x0e\x02\x0c\x03\x03\x06\x03\x10\x0a\x03\x0d\ diff --git a/tests/gen/referencetoatnparser.rs b/tests/gen/referencetoatnparser.rs index 5090303..a3aedd7 100644 --- a/tests/gen/referencetoatnparser.rs +++ b/tests/gen/referencetoatnparser.rs @@ -40,7 +40,7 @@ pub const ID: isize = 1; pub const ATN: isize = 2; pub const WS: isize = 3; pub const RULE_a: usize = 0; -pub const ruleNames: [&'static str; 1] = ["a"]; +pub const ruleNames: [&str; 1] = ["a"]; pub const _LITERAL_NAMES: [Option<&'static str>; 0] = []; pub const _SYMBOLIC_NAMES: [Option<&'static str>; 4] = [None, Some("ID"), Some("ATN"), Some("WS")]; @@ -231,8 +231,7 @@ antlr_rust::type_id! {AContextExt<'a>} impl<'input> AContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -373,7 +372,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x03\ \x05\x10\x04\x02\x09\x02\x03\x02\x07\x02\x06\x0a\x02\x0c\x02\x0e\x02\x09\ \x0b\x02\x03\x02\x05\x02\x0c\x0a\x02\x03\x02\x03\x02\x03\x02\x02\x02\x03\ diff --git a/tests/gen/simplelrlexer.rs b/tests/gen/simplelrlexer.rs index a3f8ef7..9b4dc66 100644 --- a/tests/gen/simplelrlexer.rs +++ b/tests/gen/simplelrlexer.rs @@ -30,11 +30,11 @@ use std::sync::Arc; pub const ID: isize = 1; pub const WS: isize = 2; -pub const channelNames: [&'static str; 0 + 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; +pub const channelNames: [&str; 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; -pub const modeNames: [&'static str; 1] = ["DEFAULT_MODE"]; +pub const modeNames: [&str; 1] = ["DEFAULT_MODE"]; -pub const ruleNames: [&'static str; 2] = ["ID", "WS"]; +pub const ruleNames: [&str; 2] = ["ID", "WS"]; pub const _LITERAL_NAMES: [Option<&'static str>; 0] = []; pub const _SYMBOLIC_NAMES: [Option<&'static str>; 3] = [None, Some("ID"), Some("WS")]; @@ -156,7 +156,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x02\ \x04\x10\x08\x01\x04\x02\x09\x02\x04\x03\x09\x03\x03\x02\x06\x02\x09\x0a\ \x02\x0d\x02\x0e\x02\x0a\x03\x03\x03\x03\x03\x03\x03\x03\x02\x02\x04\x03\ diff --git a/tests/gen/simplelrparser.rs b/tests/gen/simplelrparser.rs index 1f4232b..35e4140 100644 --- a/tests/gen/simplelrparser.rs +++ b/tests/gen/simplelrparser.rs @@ -40,7 +40,7 @@ pub const ID: isize = 1; pub const WS: isize = 2; pub const RULE_s: usize = 0; pub const RULE_a: usize = 1; -pub const ruleNames: [&'static str; 2] = ["s", "a"]; +pub const ruleNames: [&str; 2] = ["s", "a"]; pub const _LITERAL_NAMES: [Option<&'static str>; 0] = []; pub const _SYMBOLIC_NAMES: [Option<&'static str>; 3] = [None, Some("ID"), Some("WS")]; @@ -191,10 +191,8 @@ impl<'input, I: TokenStream<'input, TF = LocalTokenFactory<'input>> + TidAble<'i fn get_vocabulary(&self) -> &dyn Vocabulary { &**VOCABULARY } fn sempred( - _localctx: Option<&(dyn SimpleLRParserContext<'input> + 'input)>, - rule_index: isize, - pred_index: isize, - recog: &mut BaseParserType<'input, I>, + _localctx: Option<&(dyn SimpleLRParserContext<'input> + 'input)>, rule_index: isize, + pred_index: isize, recog: &mut BaseParserType<'input, I>, ) -> bool { match rule_index { 1 => SimpleLRParser::<'input, I, _>::a_sempred( @@ -212,8 +210,7 @@ where I: TokenStream<'input, TF = LocalTokenFactory<'input>> + TidAble<'input>, { fn a_sempred( - _localctx: Option<&AContext<'input>>, - pred_index: isize, + _localctx: Option<&AContext<'input>>, pred_index: isize, recog: &mut ::Target, ) -> bool { match pred_index { @@ -251,8 +248,7 @@ antlr_rust::type_id! {SContextExt<'a>} impl<'input> SContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -341,8 +337,7 @@ antlr_rust::type_id! {AContextExt<'a>} impl<'input> AContextExt<'input> { fn new( - parent: Option + 'input>>, - invoking_state: isize, + parent: Option + 'input>>, invoking_state: isize, ) -> Rc> { Rc::new(BaseParserRuleContext::new_parser_ctx( parent, @@ -463,7 +458,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x03\ \x04\x13\x04\x02\x09\x02\x04\x03\x09\x03\x03\x02\x03\x02\x03\x03\x03\x03\ \x03\x03\x03\x03\x03\x03\x07\x03\x0e\x0a\x03\x0c\x03\x0e\x03\x11\x0b\x03\ diff --git a/tests/gen/xmllexer.rs b/tests/gen/xmllexer.rs index 44cbc43..4e92e93 100644 --- a/tests/gen/xmllexer.rs +++ b/tests/gen/xmllexer.rs @@ -48,11 +48,11 @@ pub const S: isize = 17; pub const PI: isize = 18; pub const INSIDE: usize = 1; pub const PROC_INSTR: usize = 2; -pub const channelNames: [&'static str; 0 + 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; +pub const channelNames: [&str; 2] = ["DEFAULT_TOKEN_CHANNEL", "HIDDEN"]; -pub const modeNames: [&'static str; 3] = ["DEFAULT_MODE", "INSIDE", "PROC_INSTR"]; +pub const modeNames: [&str; 3] = ["DEFAULT_MODE", "INSIDE", "PROC_INSTR"]; -pub const ruleNames: [&'static str; 24] = [ +pub const ruleNames: [&str; 24] = [ "COMMENT", "CDATA", "DTD", @@ -191,8 +191,7 @@ impl<'input, Input: CharStream>> for XMLLexerActions { fn action( - _localctx: Option<&EmptyContext<'input, LocalTokenFactory<'input>>>, - rule_index: isize, + _localctx: Option<&EmptyContext<'input, LocalTokenFactory<'input>>>, rule_index: isize, action_index: isize, recog: &mut BaseLexer<'input, XMLLexerActions, Input, LocalTokenFactory<'input>>, ) { @@ -202,8 +201,7 @@ impl<'input, Input: CharStream>> } } fn sempred( - _localctx: Option<&EmptyContext<'input, LocalTokenFactory<'input>>>, - rule_index: isize, + _localctx: Option<&EmptyContext<'input, LocalTokenFactory<'input>>>, rule_index: isize, pred_index: isize, recog: &mut BaseLexer<'input, XMLLexerActions, Input, LocalTokenFactory<'input>>, ) -> bool { @@ -216,8 +214,7 @@ impl<'input, Input: CharStream>> impl<'input, Input: CharStream>> XMLLexer<'input, Input> { fn CLOSE_action( - _localctx: Option<&LexerContext<'input>>, - action_index: isize, + _localctx: Option<&LexerContext<'input>>, action_index: isize, recog: &mut ::Target, ) { match action_index { @@ -229,8 +226,7 @@ impl<'input, Input: CharStream>> XMLLexer<'input, Input> { } } fn COMMENT_sempred( - _localctx: Option<&LexerContext<'input>>, - pred_index: isize, + _localctx: Option<&LexerContext<'input>>, pred_index: isize, recog: &mut ::Target, ) -> bool { match pred_index { @@ -278,7 +274,7 @@ lazy_static! { }; } -const _serializedATN: &'static str = +const _serializedATN: &str = "\x03\u{608b}\u{a72a}\u{8133}\u{b9ed}\u{417c}\u{3be7}\u{7786}\u{5964}\x02\ \x14\u{e8}\x08\x01\x08\x01\x08\x01\x04\x02\x09\x02\x04\x03\x09\x03\x04\ \x04\x09\x04\x04\x05\x09\x05\x04\x06\x09\x06\x04\x07\x09\x07\x04\x08\x09\ diff --git a/tests/my_test.rs b/tests/my_test.rs index 8cc0b9b..890425f 100644 --- a/tests/my_test.rs +++ b/tests/my_test.rs @@ -20,8 +20,7 @@ mod gen { use antlr_rust::token_factory::{ArenaCommonFactory, OwningTokenFactory}; use antlr_rust::token_stream::{TokenStream, UnbufferedTokenStream}; use antlr_rust::tree::{ - ParseTree, ParseTreeListener, ParseTreeVisitor, ParseTreeWalker, TerminalNode, Tree, - VisitChildren, Visitable, + ParseTree, ParseTreeListener, ParseTreeVisitor, TerminalNode, Visitable, }; use antlr_rust::InputStream; use csvlexer::*; @@ -119,7 +118,7 @@ if (x < x && a > 0) then duh println!("test started lexer_test_csv"); let tf = ArenaCommonFactory::default(); let mut _lexer = CSVLexer::new_with_token_factory( - InputStream::new("V123,V2\nd1,d222".into()), + InputStream::new("V123,V2\nd1,d222"), // Box::new(UTF16InputStream::from_str("V123,V2\nd1,d222","".into())), &tf, ); @@ -180,7 +179,7 @@ if (x < x && a > 0) then duh println!("test started"); let tf = ArenaCommonFactory::default(); let mut _lexer = - CSVLexer::new_with_token_factory(InputStream::new("V123,V2\nd1,d2\n".into()), &tf); + CSVLexer::new_with_token_factory(InputStream::new("V123,V2\nd1,d2\n"), &tf); let token_source = CommonTokenStream::new(_lexer); let mut parser = CSVParser::new(token_source); parser.add_parse_listener(Box::new(Listener {})); @@ -256,7 +255,7 @@ if (x < x && a > 0) then duh #[test] fn test_lr() { - let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z".into())); + let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z")); let token_source = CommonTokenStream::new(_lexer); let mut parser = SimpleLRParser::new(token_source); parser.add_parse_listener(Box::new(Listener3)); @@ -267,7 +266,7 @@ if (x < x && a > 0) then duh #[test] fn test_immediate_lr() { - let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z".into())); + let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z")); let token_source = CommonTokenStream::new(_lexer); let mut parser = SimpleLRParser::new(token_source); parser.add_parse_listener(Box::new(Listener3)); @@ -299,7 +298,7 @@ if (x < x && a > 0) then duh #[test] fn test_remove_listener() { - let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z".into())); + let mut _lexer = SimpleLRLexer::new(InputStream::new("x y z")); let token_source = CommonTokenStream::new(_lexer); let mut parser = SimpleLRParser::new(token_source); parser.add_parse_listener(Box::new(Listener3)); @@ -380,7 +379,7 @@ if (x < x && a > 0) then duh fn test_visitor() { fn parse<'a>(tf: &'a ArenaCommonFactory<'a>) -> Rc> { let mut _lexer = - CSVLexer::new_with_token_factory(InputStream::new("h1,h2\nd1,d2\nd3\n".into()), tf); + CSVLexer::new_with_token_factory(InputStream::new("h1,h2\nd1,d2\nd3\n"), tf); let token_source = CommonTokenStream::new(_lexer); let mut parser = CSVParser::new(token_source); let result = parser.csvFile().expect("parsed unsuccessfully");