diff --git a/Cargo.toml b/Cargo.toml index 634dc23..b38189c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ missing_const_for_fn = "deny" tracing = { version = "0.1.37", optional = true } tracing-subscriber = { version = "0.3.16", optional = true, features = ["env-filter"] } tracing-flame = { version = "0.2.0", optional = true } +hashbrown = "0.14.3" [dependencies.rand] version = "0.8.0" diff --git a/src/earley/grammar.rs b/src/earley/grammar.rs index 012aae2..1c6e3cc 100644 --- a/src/earley/grammar.rs +++ b/src/earley/grammar.rs @@ -13,7 +13,7 @@ pub(crate) struct Production<'gram> { } type ProdArena<'gram> = AppendOnlyVec, ProductionId>; -type ProdTermMap<'gram> = std::collections::HashMap<&'gram crate::Term, Vec>; +type ProdTermMap<'gram> = crate::HashMap<&'gram crate::Term, Vec>; /// Similar to [`crate::Grammar`], but using [`Production`] and tables useful for parsing. #[derive(Debug)] diff --git a/src/earley/mod.rs b/src/earley/mod.rs index e077ee4..0dfcf10 100644 --- a/src/earley/mod.rs +++ b/src/earley/mod.rs @@ -5,7 +5,7 @@ mod traversal; use crate::{tracing, ParseTree, ParseTreeNode, Term}; use grammar::{ParseGrammar, Production}; use input_range::InputRange; -use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; +use std::collections::{BTreeSet, HashSet, VecDeque}; use traversal::{TermMatch, Traversal, TraversalId, TraversalTree}; pub fn parse<'gram>( @@ -224,8 +224,8 @@ impl<'gram> CompletionKey<'gram> { #[derive(Debug, Default)] pub(crate) struct CompletionMap<'gram> { - incomplete: HashMap, BTreeSet>, - complete: HashMap, BTreeSet>, + incomplete: crate::HashMap, BTreeSet>, + complete: crate::HashMap, BTreeSet>, } impl<'gram> CompletionMap<'gram> { diff --git a/src/earley/traversal.rs b/src/earley/traversal.rs index adfa515..37177d5 100644 --- a/src/earley/traversal.rs +++ b/src/earley/traversal.rs @@ -3,7 +3,6 @@ use crate::{ append_vec::{append_only_vec_id, AppendOnlyVec}, tracing, Term, }; -use std::collections::HashMap; append_only_vec_id!(pub(crate) TraversalId); @@ -55,8 +54,8 @@ struct TraversalRoot { } type TraversalArena<'gram> = AppendOnlyVec, TraversalId>; -type TreeRootMap = HashMap; -type TreeEdgeMap<'gram> = HashMap, TraversalId>; +type TreeRootMap = crate::HashMap; +type TreeEdgeMap<'gram> = crate::HashMap, TraversalId>; /// Iterator of [`TermMatch`] which resulted in the [`Traversal`]. /// Walks a [`TraversalTree`] from [`TraversalRoot`] along [`TraversalEdge`]. diff --git a/src/lib.rs b/src/lib.rs index 4fd46fc..3d95965 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,3 +15,5 @@ pub use crate::expression::Expression; pub use crate::grammar::{Grammar, ParseTree, ParseTreeNode}; pub use crate::production::Production; pub use crate::term::Term; + +pub(crate) use hashbrown::HashMap;