diff --git a/Cargo.lock b/Cargo.lock index 8c61a08d02..01b74f5513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -392,6 +392,8 @@ dependencies = [ name = "codegen_grammar" version = "0.13.0" dependencies = [ + "codegen_language_definition", + "indexmap 1.9.3", "semver", "strum_macros", ] @@ -2080,14 +2082,11 @@ dependencies = [ "anyhow", "bson", "cargo-emit", - "codegen_grammar", "codegen_language_definition", "codegen_language_macros", "codegen_schema", - "indexmap 1.9.3", "infra_utils", "semver", - "strum_macros", ] [[package]] diff --git a/crates/codegen/grammar/Cargo.toml b/crates/codegen/grammar/Cargo.toml index 7a7985dd1a..adacd96dbe 100644 --- a/crates/codegen/grammar/Cargo.toml +++ b/crates/codegen/grammar/Cargo.toml @@ -6,5 +6,7 @@ edition.workspace = true publish = false [dependencies] +codegen_language_definition = { workspace = true } +indexmap = { workspace = true } semver = { workspace = true } strum_macros = { workspace = true } diff --git a/crates/solidity/inputs/language/src/grammar.rs b/crates/codegen/grammar/src/constructor.rs similarity index 99% rename from crates/solidity/inputs/language/src/grammar.rs rename to crates/codegen/grammar/src/constructor.rs index 7ea6c0c23f..992755005b 100644 --- a/crates/solidity/inputs/language/src/grammar.rs +++ b/crates/codegen/grammar/src/constructor.rs @@ -6,15 +6,16 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::ops::Deref; use std::rc::Rc; -use codegen_grammar::{ +use codegen_language_definition::model::{self, FieldsErrorRecovery, Identifier, Item}; +use indexmap::IndexMap; + +use crate::{ Grammar, GrammarElement, KeywordScannerDefinition, KeywordScannerDefinitionNode, KeywordScannerDefinitionVersionedNode, Named, ParserDefinition, ParserDefinitionNode, PrecedenceOperatorModel, PrecedenceParserDefinition, PrecedenceParserDefinitionNode, ScannerDefinition, ScannerDefinitionNode, TriviaParserDefinition, VersionQuality, VersionQualityRange, }; -use codegen_language_definition::model::{self, FieldsErrorRecovery, Identifier, Item}; -use indexmap::IndexMap; /// Materializes the DSL v2 model ([`model::Language`]) into [`Grammar`]. pub trait GrammarConstructorDslV2 { @@ -143,7 +144,7 @@ impl KeywordScannerDefinition for NamedKeywordScanner { self.name } - fn definitions(&self) -> &[codegen_grammar::KeywordScannerDefinitionVersionedNode] { + fn definitions(&self) -> &[KeywordScannerDefinitionVersionedNode] { &self.defs } diff --git a/crates/codegen/grammar/src/lib.rs b/crates/codegen/grammar/src/lib.rs index 206e764a99..df8f06b587 100644 --- a/crates/codegen/grammar/src/lib.rs +++ b/crates/codegen/grammar/src/lib.rs @@ -1,3 +1,4 @@ +mod constructor; mod grammar; mod parser_definition; mod precedence_parser_definition; @@ -5,6 +6,7 @@ mod scanner_definition; mod version_quality; mod visitor; +pub use constructor::GrammarConstructorDslV2; pub use grammar::*; pub use parser_definition::*; pub use precedence_parser_definition::*; diff --git a/crates/solidity/inputs/language/Cargo.toml b/crates/solidity/inputs/language/Cargo.toml index f2e2c4ecb1..f559efe481 100644 --- a/crates/solidity/inputs/language/Cargo.toml +++ b/crates/solidity/inputs/language/Cargo.toml @@ -16,10 +16,7 @@ infra_utils = { workspace = true } [dependencies] anyhow = { workspace = true } bson = { workspace = true } -codegen_grammar = { workspace = true } codegen_language_definition = { workspace = true } codegen_language_macros = { workspace = true } codegen_schema = { workspace = true } -indexmap = { workspace = true } semver = { workspace = true } -strum_macros = { workspace = true } diff --git a/crates/solidity/inputs/language/src/lib.rs b/crates/solidity/inputs/language/src/lib.rs index 5f5bd40d51..f14d890aa0 100644 --- a/crates/solidity/inputs/language/src/lib.rs +++ b/crates/solidity/inputs/language/src/lib.rs @@ -7,12 +7,10 @@ //! Call the [`SolidityLanguageExtensions::load_solidity`] method to load the precompiled language definition. mod definition; -mod grammar; use anyhow::Result; use codegen_schema::types::{LanguageDefinition, LanguageDefinitionRef}; pub use definition::SolidityDefinition; -pub use grammar::GrammarConstructorDslV2; pub trait SolidityLanguageExtensions { /// Loads the precompiled Solidity language definition. diff --git a/crates/solidity/outputs/cargo/crate/build.rs b/crates/solidity/outputs/cargo/crate/build.rs index ca76c15fb0..88ce42117a 100644 --- a/crates/solidity/outputs/cargo/crate/build.rs +++ b/crates/solidity/outputs/cargo/crate/build.rs @@ -2,10 +2,10 @@ //! It is removed when publishing to crates.io. use anyhow::Result; -use codegen_grammar::Grammar; +use codegen_grammar::{Grammar, GrammarConstructorDslV2}; use codegen_parser_generator::{AstModel, RustGenerator}; use infra_utils::cargo::CargoWorkspace; -use solidity_language::{GrammarConstructorDslV2, SolidityDefinition}; +use solidity_language::SolidityDefinition; fn main() -> Result<()> { let language = SolidityDefinition::create();