Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
// let out_dir = env::var("OUT_DIR").unwrap();
// let dest_path = Path::new(&out_dir);
Expand Down
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
edition = "2018"
edition = "2021"
fn_single_line = true
fn_params_layout = "Compressed"
fn_args_layout = "Compressed"
4 changes: 1 addition & 3 deletions src/atn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Ctx>(s, None, _ctx)
Expand Down
24 changes: 6 additions & 18 deletions src/atn_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ impl ATNConfig {
}

pub fn new(
state: ATNStateRef,
alt: isize,
context: Option<Arc<PredictionContext>>,
state: ATNStateRef, alt: isize, context: Option<Arc<PredictionContext>>,
) -> ATNConfig {
ATNConfig {
precedence_filter_suppressed: false,
Expand All @@ -127,9 +125,7 @@ impl ATNConfig {
}

pub fn new_with_semantic(
state: ATNStateRef,
alt: isize,
context: Option<Arc<PredictionContext>>,
state: ATNStateRef, alt: isize, context: Option<Arc<PredictionContext>>,
semantic_context: Box<SemanticContext>,
) -> ATNConfig {
let mut new = Self::new(state, alt, context);
Expand All @@ -138,9 +134,7 @@ impl ATNConfig {
}

pub fn new_lexer_atnconfig6(
_state: ATNStateRef,
_alt: isize,
_context: Arc<PredictionContext>,
_state: ATNStateRef, _alt: isize, _context: Arc<PredictionContext>,
) -> ATNConfig {
let mut atnconfig = ATNConfig::new(_state, _alt, Some(_context));
atnconfig.config_type = ATNConfigType::LexerATNConfig {
Expand All @@ -151,9 +145,7 @@ impl ATNConfig {
}

pub fn cloned_with_new_semantic(
&self,
target: &dyn ATNState,
ctx: Box<SemanticContext>,
&self, target: &dyn ATNState, ctx: Box<SemanticContext>,
) -> ATNConfig {
let mut new = self.cloned(target);
new.semantic_context = ctx;
Expand All @@ -175,9 +167,7 @@ impl ATNConfig {
}

pub fn cloned_with_new_ctx(
&self,
target: &dyn ATNState,
ctx: Option<Arc<PredictionContext>>,
&self, target: &dyn ATNState, ctx: Option<Arc<PredictionContext>>,
) -> ATNConfig {
let mut new = self.cloned(target);
new.context = ctx;
Expand All @@ -186,9 +176,7 @@ impl ATNConfig {
}

pub(crate) fn cloned_with_new_exec(
&self,
target: &dyn ATNState,
exec: Option<LexerActionExecutor>,
&self, target: &dyn ATNState, exec: Option<LexerActionExecutor>,
) -> ATNConfig {
let mut new = self.cloned(target);
if let ATNConfigType::LexerATNConfig {
Expand Down
4 changes: 1 addition & 3 deletions src/atn_config_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ impl ATNConfigSet {
}

pub fn add_cached(
&mut self,
config: Box<ATNConfig>,
mut merge_cache: Option<&mut MergeCache>,
&mut self, config: Box<ATNConfig>, mut merge_cache: Option<&mut MergeCache>,
) -> bool {
assert!(!self.read_only);

Expand Down
26 changes: 5 additions & 21 deletions src/atn_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@ impl ATNDeserializer {
}

fn read_sets<T: Iterator<Item = isize>>(
&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<IntervalSet> {
let nsets = data.next().unwrap();
let mut sets = Vec::new();
Expand All @@ -268,10 +265,7 @@ impl ATNDeserializer {
}

fn read_edges(
&self,
atn: &mut ATN,
data: &mut dyn Iterator<Item = isize>,
sets: &Vec<IntervalSet>,
&self, atn: &mut ATN, data: &mut dyn Iterator<Item = isize>, sets: &Vec<IntervalSet>,
) {
let nedges = data.next().unwrap();

Expand Down Expand Up @@ -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<IntervalSet>,
&self, _atn: &ATN, type_index: isize, _src: ATNStateRef, target: ATNStateRef, arg1: isize,
arg2: isize, arg3: isize, sets: &Vec<IntervalSet>,
) -> Box<dyn Transition> {
// // let target = atn.states.get
// let mut base = BaseTransition {
Expand Down Expand Up @@ -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<dyn ATNState> {
let mut state = BaseATNState::new_base_atnstate();
state.state_number = state_number;
Expand Down
3 changes: 1 addition & 2 deletions src/atn_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ impl Debug for BaseATNSimulator {

impl BaseATNSimulator {
pub fn new_base_atnsimulator(
atn: Arc<ATN>,
decision_to_dfa: Arc<Vec<RwLock<DFA>>>,
atn: Arc<ATN>, decision_to_dfa: Arc<Vec<RwLock<DFA>>>,
shared_context_cache: Arc<PredictionContextCache>,
) -> BaseATNSimulator {
BaseATNSimulator {
Expand Down
3 changes: 1 addition & 2 deletions src/common_token_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<&<<Self as TokenStream<'input>>::TF as TokenFactory<'input>>::Tok> {
if k == 0 || (self.base.p - k) < 0 {
return None;
Expand Down
3 changes: 1 addition & 2 deletions src/dfa_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading