Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Use partiql_ast::ast::AstTypeMap for LocationMap
Addressing the comment in PR #389, this PR re-uses the `AstTypeMap`
for `LocationMap` which removes a dependency to `HashMap` as `AstTypeMap`
uses `IndexMap`.
  • Loading branch information
am357 committed Jun 14, 2023
commit 81926e17f8c915c6ee34776e6147c97540f89c0b
2 changes: 1 addition & 1 deletion partiql-ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/lib.rs"
bench = false

[dependencies]
indexmap = "1.9"
indexmap = { version = "1.9", features = ["serde"] }
rust_decimal = { version = "1.25.0", default-features = false, features = ["std"] }
serde = { version = "1.*", features = ["derive"], optional = true }

Expand Down
4 changes: 1 addition & 3 deletions partiql-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use parse::{parse_partiql, AstData, ErrorData};
use partiql_ast::ast;
use partiql_source_map::line_offset_tracker::LineOffsetTracker;
use partiql_source_map::location::BytePosition;

use partiql_ast::ast::NodeId;
use partiql_source_map::metadata::LocationMap;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -82,7 +80,7 @@ pub struct Parsed<'input> {
pub text: &'input str,
pub offsets: LineOffsetTracker,
pub ast: Box<ast::Expr>,
pub locations: LocationMap<NodeId>,
pub locations: LocationMap,
}

/// The output of errors when parsing PartiQL statement strings: an errors and auxiliary data.
Expand Down
4 changes: 2 additions & 2 deletions partiql-parser/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::parse::parser_state::{IdGenerator, ParserState};
use crate::preprocessor::{PreprocessingPartiqlLexer, BUILT_INS};
use lalrpop_util as lpop;
use partiql_ast::ast;
use partiql_ast::ast::NodeId;
use partiql_source_map::line_offset_tracker::LineOffsetTracker;
use partiql_source_map::location::{ByteOffset, BytePosition, ToLocated};
use partiql_source_map::metadata::LocationMap;
Expand Down Expand Up @@ -41,7 +40,7 @@ type LalrpopErrorRecovery<'input> =
#[derive(Debug, Clone)]
pub(crate) struct AstData {
pub ast: Box<ast::Expr>,
pub locations: LocationMap<NodeId>,
pub locations: LocationMap,
pub offsets: LineOffsetTracker,
}

Expand Down Expand Up @@ -535,6 +534,7 @@ mod tests {

mod set_ops {
use super::*;
use partiql_ast::ast::NodeId;

#[derive(Default)]
pub(crate) struct NullIdGenerator {}
Expand Down
2 changes: 1 addition & 1 deletion partiql-parser/src/parse/parser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub(crate) struct ParserState<'input, Id: IdGenerator> {
/// Generator for 'fresh' [`NodeId`]s
pub id_gen: Id,
/// Maps AST [`NodeId`]s to the location in the source from which each was derived.
pub locations: LocationMap<NodeId>,
pub locations: LocationMap,
/// Any errors accumulated during parse.
pub errors: ParseErrors<'input>,

Expand Down
2 changes: 2 additions & 0 deletions partiql-source-map/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ edition.workspace = true
bench = false

[dependencies]
partiql-ast = { path = "../partiql-ast", version = "0.5.*" }

smallvec = { version = "1.*" }
serde = { version = "1.*", features = ["derive"], optional = true }

Expand Down
4 changes: 2 additions & 2 deletions partiql-source-map/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::location::{BytePosition, Location};
use std::collections::HashMap;
use partiql_ast::ast::AstTypeMap;

/// Map of `T` to a [`Location<BytePosition>>`]
pub type LocationMap<T> = HashMap<T, Location<BytePosition>>;
pub type LocationMap = AstTypeMap<Location<BytePosition>>;