diff --git a/Cargo.lock b/Cargo.lock index c16cf9086..8b65c1c98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -405,7 +405,6 @@ dependencies = [ "codegen_runtime_generator", "metaslang_bindings", "metaslang_cst", - "metaslang_graph_builder", "napi", "napi-derive", "semver", @@ -2121,7 +2120,6 @@ dependencies = [ "infra_utils", "metaslang_bindings", "metaslang_cst", - "metaslang_graph_builder", "semver", "serde", "serde_json", @@ -2156,7 +2154,6 @@ dependencies = [ "infra_utils", "metaslang_bindings", "metaslang_cst", - "metaslang_graph_builder", "semver", "serde", "strum", @@ -2476,6 +2473,7 @@ dependencies = [ name = "testlang_cargo_tests" version = "0.15.1" dependencies = [ + "metaslang_graph_builder", "semver", "slang_testlang", ] diff --git a/crates/codegen/runtime/cargo/Cargo.toml b/crates/codegen/runtime/cargo/Cargo.toml index e45150342..3ede85ec1 100644 --- a/crates/codegen/runtime/cargo/Cargo.toml +++ b/crates/codegen/runtime/cargo/Cargo.toml @@ -16,7 +16,6 @@ ariadne = { workspace = true, optional = true } clap = { workspace = true, optional = true } metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -metaslang_graph_builder = { workspace = true, optional = true } napi = { workspace = true, optional = true } napi-derive = { workspace = true, optional = true } semver = { workspace = true } @@ -35,7 +34,7 @@ cli = ["dep:clap", "dep:serde_json", "__private_ariadne"] # Only used by the `slang_solidity` CLI __private_ariadne = ["dep:ariadne"] # For internal development only -__experimental_bindings_api = ["dep:metaslang_bindings", "dep:metaslang_graph_builder"] +__experimental_bindings_api = ["dep:metaslang_bindings"] [lints] workspace = true diff --git a/crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs b/crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs index 56f9eb414..f26d12db7 100644 --- a/crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs @@ -1,18 +1,6 @@ #[path = "generated/binding_rules.rs"] mod binding_rules; -pub mod graph_builder { - use metaslang_graph_builder::{ast, functions, graph}; - - use crate::cst::KindTypes; - - pub type File = ast::File; - pub type Functions = functions::Functions; - pub type Graph = graph::Graph; - - pub use metaslang_graph_builder::{ExecutionConfig, NoCancellation, Variables}; -} - use metaslang_bindings; pub use metaslang_bindings::BindingsError; use semver::Version; diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/commands/build_graph.rs b/crates/codegen/runtime/cargo/src/runtime/cli/commands/build_graph.rs deleted file mode 100644 index c351e2af2..000000000 --- a/crates/codegen/runtime/cargo/src/runtime/cli/commands/build_graph.rs +++ /dev/null @@ -1,55 +0,0 @@ -use std::fs; -use std::path::PathBuf; - -use semver::Version; - -use super::parse::parse_source_file; -use super::CommandError; -use crate::bindings::graph_builder::{self, ExecutionConfig, File, Functions, Variables}; - -pub fn execute( - file_path_string: &str, - version: Version, - msgb_path_string: &str, - output_json: bool, - debug: bool, -) -> Result<(), CommandError> { - let parse_output = parse_source_file(file_path_string, version, |_| ())?; - let msgb = parse_graph_builder(msgb_path_string)?; - - let functions = Functions::stdlib(); - let variables = Variables::new(); - let mut execution_config = ExecutionConfig::new(&functions, &variables); - if debug { - execution_config = execution_config.debug_attributes( - "_location".into(), - "_variable".into(), - "_match".into(), - ); - } - - let tree = parse_output.create_tree_cursor(); - let graph = msgb.execute(&tree, &execution_config, &graph_builder::NoCancellation)?; - - if output_json { - graph.display_json(None)?; - } else { - print!("{}", graph.pretty_print()); - } - - Ok(()) -} - -pub(crate) fn parse_graph_builder(msgb_path_string: &str) -> Result { - let msgb_path = PathBuf::from(&msgb_path_string) - .canonicalize() - .map_err(|_| CommandError::FileNotFound(msgb_path_string.to_string()))?; - - let msgb_source = fs::read_to_string(&msgb_path)?; - File::from_str(&msgb_source).map_err(|parser_error| { - let error_message = parser_error - .display_pretty(&msgb_path, &msgb_source) - .to_string(); - CommandError::ParseFailed(error_message) - }) -} diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs b/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs index e3c0ad8ed..1658b10bf 100644 --- a/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs @@ -2,8 +2,6 @@ use thiserror::Error; #[cfg(feature = "__experimental_bindings_api")] pub mod bindings; -#[cfg(feature = "__experimental_bindings_api")] -pub mod build_graph; pub mod parse; #[derive(Debug, Error)] @@ -20,10 +18,6 @@ pub enum CommandError { #[error("Parsing failed: {0}")] ParseFailed(String), - #[cfg(feature = "__experimental_bindings_api")] - #[error(transparent)] - ExecutionFailed(#[from] metaslang_graph_builder::ExecutionError), - #[cfg(feature = "__experimental_bindings_api")] #[error(transparent)] BuildError(#[from] metaslang_bindings::builder::BuildError), diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs b/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs index 8c39f45cf..370ff6a9c 100644 --- a/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs @@ -21,29 +21,6 @@ pub enum Commands { json: bool, }, - // This is only intended for internal development - #[cfg(feature = "__experimental_bindings_api")] - /// Parses a source file and builds a graph executing the instructions from the builder file (*.msgb) - BuildGraph { - /// File path to the source file to parse - file_path: String, - - /// The language version to use for parsing - #[arg(short, long)] - version: Version, - - /// The graph buider (.msgb) file to use - msgb_path: String, - - /// Print the graph as JSON - #[clap(long)] - json: bool, - - /// Include debug info (location, variable and match) in the built graph - #[clap(long)] - debug: bool, - }, - /// This is only intended for internal development #[cfg(feature = "__experimental_bindings_api")] Bindings { @@ -65,14 +42,6 @@ impl Commands { json, } => commands::parse::execute(&file_path, version, json), #[cfg(feature = "__experimental_bindings_api")] - Commands::BuildGraph { - file_path, - version, - msgb_path, - json, - debug, - } => commands::build_graph::execute(&file_path, version, &msgb_path, json, debug), - #[cfg(feature = "__experimental_bindings_api")] Commands::Bindings { file_path, version } => { commands::bindings::execute(&file_path, version) } diff --git a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml index 25001b223..a11d7e0ea 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml +++ b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml @@ -37,7 +37,7 @@ cli = ["dep:clap", "dep:serde_json", "__private_ariadne"] # This is meant to be used by the CLI or internally only. __private_ariadne = ["dep:ariadne"] # For internal development only -__experimental_bindings_api = ["dep:metaslang_bindings", "dep:metaslang_graph_builder"] +__experimental_bindings_api = ["dep:metaslang_bindings"] [build-dependencies] # __REMOVE_THIS_LINE_DURING_CARGO_PUBLISH__ anyhow = { workspace = true } # __REMOVE_THIS_LINE_DURING_CARGO_PUBLISH__ @@ -50,7 +50,6 @@ ariadne = { workspace = true, optional = true } clap = { workspace = true, optional = true } metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -metaslang_graph_builder = { workspace = true, optional = true } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true, optional = true } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs index 633c2df26..693c5ea15 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs @@ -3,18 +3,6 @@ #[path = "generated/binding_rules.rs"] mod binding_rules; -pub mod graph_builder { - use metaslang_graph_builder::{ast, functions, graph}; - - use crate::cst::KindTypes; - - pub type File = ast::File; - pub type Functions = functions::Functions; - pub type Graph = graph::Graph; - - pub use metaslang_graph_builder::{ExecutionConfig, NoCancellation, Variables}; -} - use metaslang_bindings; pub use metaslang_bindings::BindingsError; use semver::Version; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/build_graph.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/build_graph.rs deleted file mode 100644 index 3132d8f69..000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/build_graph.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use std::fs; -use std::path::PathBuf; - -use semver::Version; - -use super::parse::parse_source_file; -use super::CommandError; -use crate::bindings::graph_builder::{self, ExecutionConfig, File, Functions, Variables}; - -pub fn execute( - file_path_string: &str, - version: Version, - msgb_path_string: &str, - output_json: bool, - debug: bool, -) -> Result<(), CommandError> { - let parse_output = parse_source_file(file_path_string, version, |_| ())?; - let msgb = parse_graph_builder(msgb_path_string)?; - - let functions = Functions::stdlib(); - let variables = Variables::new(); - let mut execution_config = ExecutionConfig::new(&functions, &variables); - if debug { - execution_config = execution_config.debug_attributes( - "_location".into(), - "_variable".into(), - "_match".into(), - ); - } - - let tree = parse_output.create_tree_cursor(); - let graph = msgb.execute(&tree, &execution_config, &graph_builder::NoCancellation)?; - - if output_json { - graph.display_json(None)?; - } else { - print!("{}", graph.pretty_print()); - } - - Ok(()) -} - -pub(crate) fn parse_graph_builder(msgb_path_string: &str) -> Result { - let msgb_path = PathBuf::from(&msgb_path_string) - .canonicalize() - .map_err(|_| CommandError::FileNotFound(msgb_path_string.to_string()))?; - - let msgb_source = fs::read_to_string(&msgb_path)?; - File::from_str(&msgb_source).map_err(|parser_error| { - let error_message = parser_error - .display_pretty(&msgb_path, &msgb_source) - .to_string(); - CommandError::ParseFailed(error_message) - }) -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs index 2d6ea428f..ab5496ce8 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs @@ -4,8 +4,6 @@ use thiserror::Error; #[cfg(feature = "__experimental_bindings_api")] pub mod bindings; -#[cfg(feature = "__experimental_bindings_api")] -pub mod build_graph; pub mod parse; #[derive(Debug, Error)] @@ -22,10 +20,6 @@ pub enum CommandError { #[error("Parsing failed: {0}")] ParseFailed(String), - #[cfg(feature = "__experimental_bindings_api")] - #[error(transparent)] - ExecutionFailed(#[from] metaslang_graph_builder::ExecutionError), - #[cfg(feature = "__experimental_bindings_api")] #[error(transparent)] BuildError(#[from] metaslang_bindings::builder::BuildError), diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs index 6e8190b9f..78852ab54 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs @@ -23,29 +23,6 @@ pub enum Commands { json: bool, }, - // This is only intended for internal development - #[cfg(feature = "__experimental_bindings_api")] - /// Parses a source file and builds a graph executing the instructions from the builder file (*.msgb) - BuildGraph { - /// File path to the source file to parse - file_path: String, - - /// The language version to use for parsing - #[arg(short, long)] - version: Version, - - /// The graph buider (.msgb) file to use - msgb_path: String, - - /// Print the graph as JSON - #[clap(long)] - json: bool, - - /// Include debug info (location, variable and match) in the built graph - #[clap(long)] - debug: bool, - }, - /// This is only intended for internal development #[cfg(feature = "__experimental_bindings_api")] Bindings { @@ -67,14 +44,6 @@ impl Commands { json, } => commands::parse::execute(&file_path, version, json), #[cfg(feature = "__experimental_bindings_api")] - Commands::BuildGraph { - file_path, - version, - msgb_path, - json, - debug, - } => commands::build_graph::execute(&file_path, version, &msgb_path, json, debug), - #[cfg(feature = "__experimental_bindings_api")] Commands::Bindings { file_path, version } => { commands::bindings::execute(&file_path, version) } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs index e2af9d385..867753670 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs @@ -8,12 +8,12 @@ use slang_solidity::cli::Commands; // This is a known issue, and we should remove this hack once there is a better solution from Cargo. // https://github.com/rust-lang/cargo/issues/1982 mod supress_api_dependencies { + #[cfg(feature = "__experimental_bindings_api")] + use metaslang_bindings as _; use { ariadne as _, metaslang_cst as _, semver as _, serde as _, serde_json as _, strum as _, strum_macros as _, thiserror as _, }; - #[cfg(feature = "__experimental_bindings_api")] - use {metaslang_bindings as _, metaslang_graph_builder as _}; } #[derive(ClapParser, Debug)] diff --git a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml index 197b73918..639f3428f 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml +++ b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml @@ -15,7 +15,6 @@ testlang_language = { workspace = true } [dependencies] metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -metaslang_graph_builder = { workspace = true, optional = true } semver = { workspace = true } serde = { workspace = true } strum = { workspace = true } @@ -26,4 +25,4 @@ thiserror = { workspace = true } workspace = true [features] -__experimental_bindings_api = ["dep:metaslang_bindings", "dep:metaslang_graph_builder"] +__experimental_bindings_api = ["dep:metaslang_bindings"] diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs index 633c2df26..693c5ea15 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs @@ -3,18 +3,6 @@ #[path = "generated/binding_rules.rs"] mod binding_rules; -pub mod graph_builder { - use metaslang_graph_builder::{ast, functions, graph}; - - use crate::cst::KindTypes; - - pub type File = ast::File; - pub type Functions = functions::Functions; - pub type Graph = graph::Graph; - - pub use metaslang_graph_builder::{ExecutionConfig, NoCancellation, Variables}; -} - use metaslang_bindings; pub use metaslang_bindings::BindingsError; use semver::Version; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/build_graph.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/build_graph.rs deleted file mode 100644 index 3132d8f69..000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/build_graph.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use std::fs; -use std::path::PathBuf; - -use semver::Version; - -use super::parse::parse_source_file; -use super::CommandError; -use crate::bindings::graph_builder::{self, ExecutionConfig, File, Functions, Variables}; - -pub fn execute( - file_path_string: &str, - version: Version, - msgb_path_string: &str, - output_json: bool, - debug: bool, -) -> Result<(), CommandError> { - let parse_output = parse_source_file(file_path_string, version, |_| ())?; - let msgb = parse_graph_builder(msgb_path_string)?; - - let functions = Functions::stdlib(); - let variables = Variables::new(); - let mut execution_config = ExecutionConfig::new(&functions, &variables); - if debug { - execution_config = execution_config.debug_attributes( - "_location".into(), - "_variable".into(), - "_match".into(), - ); - } - - let tree = parse_output.create_tree_cursor(); - let graph = msgb.execute(&tree, &execution_config, &graph_builder::NoCancellation)?; - - if output_json { - graph.display_json(None)?; - } else { - print!("{}", graph.pretty_print()); - } - - Ok(()) -} - -pub(crate) fn parse_graph_builder(msgb_path_string: &str) -> Result { - let msgb_path = PathBuf::from(&msgb_path_string) - .canonicalize() - .map_err(|_| CommandError::FileNotFound(msgb_path_string.to_string()))?; - - let msgb_source = fs::read_to_string(&msgb_path)?; - File::from_str(&msgb_source).map_err(|parser_error| { - let error_message = parser_error - .display_pretty(&msgb_path, &msgb_source) - .to_string(); - CommandError::ParseFailed(error_message) - }) -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs index 2d6ea428f..ab5496ce8 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs @@ -4,8 +4,6 @@ use thiserror::Error; #[cfg(feature = "__experimental_bindings_api")] pub mod bindings; -#[cfg(feature = "__experimental_bindings_api")] -pub mod build_graph; pub mod parse; #[derive(Debug, Error)] @@ -22,10 +20,6 @@ pub enum CommandError { #[error("Parsing failed: {0}")] ParseFailed(String), - #[cfg(feature = "__experimental_bindings_api")] - #[error(transparent)] - ExecutionFailed(#[from] metaslang_graph_builder::ExecutionError), - #[cfg(feature = "__experimental_bindings_api")] #[error(transparent)] BuildError(#[from] metaslang_bindings::builder::BuildError), diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs index 6e8190b9f..78852ab54 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs @@ -23,29 +23,6 @@ pub enum Commands { json: bool, }, - // This is only intended for internal development - #[cfg(feature = "__experimental_bindings_api")] - /// Parses a source file and builds a graph executing the instructions from the builder file (*.msgb) - BuildGraph { - /// File path to the source file to parse - file_path: String, - - /// The language version to use for parsing - #[arg(short, long)] - version: Version, - - /// The graph buider (.msgb) file to use - msgb_path: String, - - /// Print the graph as JSON - #[clap(long)] - json: bool, - - /// Include debug info (location, variable and match) in the built graph - #[clap(long)] - debug: bool, - }, - /// This is only intended for internal development #[cfg(feature = "__experimental_bindings_api")] Bindings { @@ -67,14 +44,6 @@ impl Commands { json, } => commands::parse::execute(&file_path, version, json), #[cfg(feature = "__experimental_bindings_api")] - Commands::BuildGraph { - file_path, - version, - msgb_path, - json, - debug, - } => commands::build_graph::execute(&file_path, version, &msgb_path, json, debug), - #[cfg(feature = "__experimental_bindings_api")] Commands::Bindings { file_path, version } => { commands::bindings::execute(&file_path, version) } diff --git a/crates/testlang/outputs/cargo/tests/Cargo.toml b/crates/testlang/outputs/cargo/tests/Cargo.toml index 637d232b0..e014cc4c4 100644 --- a/crates/testlang/outputs/cargo/tests/Cargo.toml +++ b/crates/testlang/outputs/cargo/tests/Cargo.toml @@ -6,6 +6,7 @@ edition.workspace = true publish = false [dev-dependencies] +metaslang_graph_builder = { workspace = true } semver = { workspace = true } slang_testlang = { workspace = true, features = [ "__experimental_bindings_api", diff --git a/crates/testlang/outputs/cargo/tests/src/graph/mod.rs b/crates/testlang/outputs/cargo/tests/src/graph/mod.rs index e649bc2e3..a8eaa4560 100644 --- a/crates/testlang/outputs/cargo/tests/src/graph/mod.rs +++ b/crates/testlang/outputs/cargo/tests/src/graph/mod.rs @@ -1,7 +1,7 @@ +use metaslang_graph_builder::ast::File; +use metaslang_graph_builder::functions::Functions; +use metaslang_graph_builder::{ExecutionConfig, NoCancellation, Variables}; use semver::Version; -use slang_testlang::bindings::graph_builder::{ - ExecutionConfig, File, Functions, NoCancellation, Variables, -}; use slang_testlang::kinds::NonterminalKind; use slang_testlang::language::Language;