Skip to content

Commit

Permalink
move Rust's syntax::parser::Language API to root module
Browse files Browse the repository at this point in the history
As it will contain APIs other than the parser in the future
  • Loading branch information
OmarTawfik committed May 10, 2023
1 parent 7dfb617 commit eb95e89
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-spies-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"changelog": minor
---

move Rust's `syntax::Parser::Language` API to root module
2 changes: 1 addition & 1 deletion crates/solidity/outputs/cargo/build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> Result<()> {

let output_dir = codegen
.repo_root
.join("crates/solidity/outputs/cargo/crate/src/syntax/generated");
.join("crates/solidity/outputs/cargo/crate/src/generated");

grammar.generate_rust_lib_sources(codegen, &output_dir);
return Ok(());
Expand Down
25 changes: 24 additions & 1 deletion crates/solidity/outputs/cargo/crate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod syntax;
mod generated;

mod _supress_binary_dependencies_ {
// Below are dependencies used by the binary `main.rs`, but not here.
Expand All @@ -12,3 +12,26 @@ mod _supress_binary_dependencies_ {
use solidity_cargo_build as _;
use thiserror as _;
}

pub use public_api::*;

mod public_api {
pub use crate::generated::language::Language;

pub mod syntax {
pub mod nodes {
pub use crate::generated::cst::Node;
pub use crate::generated::kinds::{RuleKind, TokenKind};
}

pub mod parser {
pub use crate::generated::language::{ParseOutput, ProductionKind};
}

pub mod visitors {
pub use crate::generated::cst_visitor::{
Visitable, Visitor, VisitorEntryResponse, VisitorExitResponse,
};
}
}
}
2 changes: 1 addition & 1 deletion crates/solidity/outputs/cargo/crate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{fs, path::PathBuf};
use anyhow::Result;
use clap::{Parser as ClapParser, Subcommand};
use semver::Version;
use slang_solidity::syntax::parser::{Language, ProductionKind};
use slang_solidity::{syntax::parser::ProductionKind, Language};

mod _supress_library_dependencies_ {
// Below are dependencies used by the library `lib.rs`, but not here.
Expand Down
16 changes: 0 additions & 16 deletions crates/solidity/outputs/cargo/crate/src/syntax/mod.rs

This file was deleted.

5 changes: 4 additions & 1 deletion crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::str::FromStr;
use anyhow::Result;
use codegen_utils::context::CodegenContext;
use semver::Version;
use slang_solidity::syntax::parser::{Language, ParseOutput, ProductionKind};
use slang_solidity::{
syntax::parser::{ParseOutput, ProductionKind},
Language,
};
use solidity_testing_utils::cst_snapshots::ParseOutputTestSnapshotExtensions;

use crate::cst_output::generated::VERSION_BREAKS;
Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/outputs/npm/build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> Result<()> {

let output_dir = codegen
.repo_root
.join("crates/solidity/outputs/npm/crate/src/syntax/generated");
.join("crates/solidity/outputs/npm/crate/src/generated");

grammar.generate_typescript_lib_sources(codegen, &output_dir);

Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/outputs/npm/crate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ extern crate napi_derive;
#[cfg(test)]
use solidity_npm_build as _;

pub mod syntax;
pub mod generated;
1 change: 0 additions & 1 deletion crates/solidity/outputs/npm/crate/src/syntax/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/solidity/testing/smoke/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::Result;
use codegen_schema::types::grammar::Grammar;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
use semver::Version;
use slang_solidity::syntax::parser::{Language, ProductionKind};
use slang_solidity::{syntax::parser::ProductionKind, Language};
use solidity_schema::SolidityGrammarExtensions;
use solidity_testing_utils::version_pragmas::extract_version_pragmas;

Expand Down
2 changes: 1 addition & 1 deletion crates/solidity/testing/utils/src/node_extensions/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{Context, Result};
use semver::Version;
use slang_solidity::syntax::parser::{Language, ProductionKind};
use slang_solidity::{syntax::parser::ProductionKind, Language};

use crate::node_extensions::NodeExtensions;

Expand Down
11 changes: 7 additions & 4 deletions crates/solidity/testing/utils/src/version_pragmas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ use std::{ops::Range, rc::Rc, str::FromStr};

use anyhow::{bail, Context, Error, Result};
use semver::{Comparator, Op, Version};
use slang_solidity::syntax::{
nodes::{Node, RuleKind},
parser::{Language, ProductionKind},
visitors::{Visitable, Visitor, VisitorEntryResponse},
use slang_solidity::{
syntax::{
nodes::{Node, RuleKind},
parser::ProductionKind,
visitors::{Visitable, Visitor, VisitorEntryResponse},
},
Language,
};

use crate::node_extensions::NodeExtensions;
Expand Down

0 comments on commit eb95e89

Please sign in to comment.