Skip to content

Commit

Permalink
Generify CST/Cursor/Query
Browse files Browse the repository at this point in the history
This rebases #930 after applying recent infra changes.
  • Loading branch information
OmarTawfik committed May 16, 2024
1 parent 874039b commit a34cf42
Show file tree
Hide file tree
Showing 105 changed files with 1,082 additions and 4,053 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-hotels-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

refactor CST building and querying utilities into a separate `metaslang_cst` crate.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"inheritdoc",
"instanceof",
"ipfs",
"metaslang",
"mkdocs",
"napi",
"nomic",
Expand Down
21 changes: 15 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ members = [
"crates/infra/cli",
"crates/infra/utils",

"crates/metaslang/cst",

"crates/solidity/inputs/language",
"crates/solidity/outputs/cargo/slang_solidity_node_addon",
"crates/solidity/outputs/cargo/slang_solidity",
Expand Down Expand Up @@ -60,6 +62,8 @@ codegen_testing = { path = "crates/codegen/testing" }
infra_cli = { path = "crates/infra/cli" }
infra_utils = { path = "crates/infra/utils" }

metaslang_cst = { path = "crates/metaslang/cst" }

slang_solidity = { path = "crates/solidity/outputs/cargo/slang_solidity" }
slang_solidity_node_addon = { path = "crates/solidity/outputs/cargo/slang_solidity_node_addon" }
solidity_cargo_tests = { path = "crates/solidity/outputs/cargo/tests" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod definitions;
mod queries;
mod reachability;
mod references;
mod utils;
Expand All @@ -10,7 +9,6 @@ use indexmap::IndexMap;
use proc_macro2::Span;

use crate::compiler::analysis::definitions::analyze_definitions;
use crate::compiler::analysis::queries::analyze_queries;
use crate::compiler::analysis::reachability::analyze_reachability;
use crate::compiler::analysis::references::analyze_references;
use crate::compiler::version_set::VersionSet;
Expand Down Expand Up @@ -64,7 +62,6 @@ impl Analysis {
}

analyze_reachability(&mut analysis);
analyze_queries(&mut analysis);

analysis
}
Expand Down

This file was deleted.

4 changes: 1 addition & 3 deletions crates/codegen/language/definition/src/model/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf;

use codegen_language_internal_macros::{derive_spanned_type, ParseInputTokens, WriteOutputTokens};
use indexmap::{IndexMap, IndexSet};
use indexmap::IndexSet;
use semver::Version;
use serde::{Deserialize, Serialize};

Expand All @@ -22,8 +22,6 @@ pub struct Language {
pub versions: IndexSet<Version>,

pub sections: Vec<Section>,

pub queries: IndexMap<Identifier, String>,
}

impl Language {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ codegen_language_macros::compile!(Language(
Struct(name = Bar2, fields = (field = Required(Bar1)))
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ codegen_language_macros::compile!(Language(
definitions = [TokenDefinition(scanner = Atom("bar"))]
)]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ codegen_language_macros::compile!(Language(
definitions = [TokenDefinition(scanner = Atom(""))]
)]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ codegen_language_macros::compile!(Language(
sections = [Section(
// title = "Section One"
topics = []
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ codegen_language_macros::compile!(Language(
)],
unrecognized_field = true
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ codegen_language_macros::compile!(Language(
),
Topic(title = "Topic Two", items = [Unrecognized(true)])
]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ codegen_language_macros::compile!(Language(
Struct(name = Baz2, fields = (field = Required(Baz1)))
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ codegen_language_macros::compile!(Language(
Fragment(name = Baz, scanner = Atom("baz"))
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

fn main() {}
6 changes: 2 additions & 4 deletions crates/codegen/language/tests/src/pass/tiny_language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ codegen_language_macros::compile!(Language(
)
]
)]
)],
queries = ()
)]
));

#[test]
Expand Down Expand Up @@ -118,8 +117,7 @@ fn definition() {
]
.into()
}],
}],
queries: [].into()
}]
}
.into(),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/codegen/runtime/cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ codegen_runtime_generator = { workspace = true }

[dependencies]
ariadne = { workspace = true }
metaslang_cst = { workspace = true }
napi = { workspace = true, optional = true }
napi-derive = { workspace = true, optional = true }
nom = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true, optional = true }
Expand Down
1 change: 0 additions & 1 deletion crates/codegen/runtime/cargo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(dead_code)]

mod runtime;
mod user_defined;

pub use runtime::*;
Loading

0 comments on commit a34cf42

Please sign in to comment.