diff --git a/.vscode/settings.json b/.vscode/settings.json index acf4fa8a58..5f356923f8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,7 +26,7 @@ "**/Pipfile.lock": true }, "triggerTaskOnSave.tasks": { - "Validate Solidity Grammar": ["crates/solidity/inputs/schema/grammar/**/*.yml"] + "Validate Solidity Schema": ["crates/solidity/inputs/schema/definition/**/*.yml"] }, "typescript.tsdk": "node_modules/typescript/lib", "yaml.validate": false // Disable LSP validation for YAML files, as it is handled by our own cargo tasks diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 91866f62dc..2a58351d2a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,9 +2,9 @@ "version": "2.0.0", "tasks": [ { - "label": "Validate Solidity Grammar", + "label": "Validate Solidity Schema", "type": "shell", - "command": "scripts/solidity/check-grammar.sh", + "command": "scripts/solidity/validate-schema.sh", "options": { "env": { "VSCODE_PROBLEM_MATCHER": "true" diff --git a/crates/codegen/ebnf/src/serialization.rs b/crates/codegen/ebnf/src/serialization.rs index e19cd15e05..414ef3b899 100644 --- a/crates/codegen/ebnf/src/serialization.rs +++ b/crates/codegen/ebnf/src/serialization.rs @@ -1,8 +1,8 @@ use std::{collections::VecDeque, mem::discriminant}; use codegen_schema::types::{ - grammar::Grammar, production::{Production, ProductionRef}, + schema::Schema, }; use semver::Version; @@ -12,18 +12,18 @@ pub trait GenerateEbnf { fn generate_ebnf(&self) -> EbnfNode; } -pub struct EbnfSerializer<'grammar> { - grammar: &'grammar Grammar, - base_production: &'grammar str, +pub struct EbnfSerializer<'schema> { + schema: &'schema Schema, + base_production: &'schema str, buffer: String, queue: VecDeque<(String, Option, EbnfNode)>, } -impl<'grammar> EbnfSerializer<'grammar> { +impl<'schema> EbnfSerializer<'schema> { pub fn serialize_version( - grammar: &'grammar Grammar, - production: &'grammar ProductionRef, + schema: &'schema Schema, + production: &'schema ProductionRef, version: &Version, ) -> Option { let body = match production.as_ref() { @@ -42,7 +42,7 @@ impl<'grammar> EbnfSerializer<'grammar> { }; let mut instance = Self { - grammar, + schema, buffer: String::new(), base_production: production.name(), queue: VecDeque::new(), @@ -186,7 +186,7 @@ impl<'grammar> EbnfSerializer<'grammar> { } fn display_name(&self, name: &String) -> String { - if let Some(production) = self.grammar.productions.get(name) { + if let Some(production) = self.schema.productions.get(name) { if matches!(production.as_ref(), Production::Scanner { .. }) { return format!("«{name}»"); } diff --git a/crates/codegen/schema/src/compiler.rs b/crates/codegen/schema/src/compiler.rs index 3e2cc73c17..39d4667c0b 100644 --- a/crates/codegen/schema/src/compiler.rs +++ b/crates/codegen/schema/src/compiler.rs @@ -7,16 +7,16 @@ use codegen_utils::{ use crate::{ types::{ - grammar::{Grammar, GrammarSection, GrammarTopic}, manifest::{ManifestFile, ManifestSection, ProductionsFile}, + schema::{Schema, SchemaSection, SchemaTopic}, }, validation::Model, yaml, }; -impl Grammar { - pub fn compile(codegen: &mut CodegenContext, manifest_dir: PathBuf) -> CodegenResult { - let manifest_path = manifest_dir.join("manifest.yml"); +impl Schema { + pub fn compile(codegen: &mut CodegenContext, schema_dir: PathBuf) -> CodegenResult { + let manifest_path = schema_dir.join("manifest.yml"); let manifest_file = yaml::files::File::::load(codegen, manifest_path)?; let mut model = Model::new(&manifest_file)?; @@ -24,7 +24,7 @@ impl Grammar { let sections = load_sections( codegen, &mut model, - &manifest_dir, + &schema_dir, &manifest_file.value.sections, )?; @@ -37,12 +37,12 @@ impl Grammar { .map(|(name, production)| (name.to_owned(), production.clone())) .collect(); - return Ok(Grammar { + return Ok(Schema { title: manifest_file.value.title, versions: manifest_file.value.versions, sections, - manifest_dir, + schema_dir, productions, }); } @@ -51,26 +51,26 @@ impl Grammar { fn load_sections( codegen: &mut CodegenContext, model: &mut Model, - grammar_dir: &PathBuf, + schema_dir: &PathBuf, sections: &Vec, -) -> CodegenResult> { - let mut results = Vec::::new(); +) -> CodegenResult> { + let mut results = Vec::::new(); let mut errors = CodegenErrors::new(); for section in sections { - let mut topics = Vec::::new(); + let mut topics = Vec::::new(); for topic in §ion.topics { - let productions_path = grammar_dir + let productions_path = schema_dir .join(§ion.path) .join(&topic.path) - .join(GrammarTopic::productions_file()); + .join(SchemaTopic::productions_file()); match yaml::files::File::::load(codegen, productions_path) { Ok(productions_file) => { model.add_productions_file(&productions_file); - topics.push(GrammarTopic { + topics.push(SchemaTopic { title: topic.title.to_owned(), path: topic.path.to_owned(), productions: productions_file @@ -86,7 +86,7 @@ fn load_sections( }; } - results.push(GrammarSection { + results.push(SchemaSection { title: section.title.to_owned(), path: section.path.to_owned(), topics, diff --git a/crates/codegen/schema/src/types/mod.rs b/crates/codegen/schema/src/types/mod.rs index a86f40faa2..a6896f2457 100644 --- a/crates/codegen/schema/src/types/mod.rs +++ b/crates/codegen/schema/src/types/mod.rs @@ -1,7 +1,7 @@ pub(crate) mod manifest; // internal, used for serialization/validation only -pub mod grammar; pub mod parser; pub mod precedence_parser; pub mod production; pub mod scanner; +pub mod schema; diff --git a/crates/codegen/schema/src/types/grammar.rs b/crates/codegen/schema/src/types/schema.rs similarity index 77% rename from crates/codegen/schema/src/types/grammar.rs rename to crates/codegen/schema/src/types/schema.rs index d31eb1bcc6..38c98f4e07 100644 --- a/crates/codegen/schema/src/types/grammar.rs +++ b/crates/codegen/schema/src/types/schema.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, path::PathBuf}; +use std::path::PathBuf; use indexmap::IndexMap; use semver::Version; @@ -8,32 +8,32 @@ use super::production::ProductionRef; #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(deny_unknown_fields)] -pub struct Grammar { +pub struct Schema { pub title: String, - pub sections: Vec, + pub sections: Vec, pub versions: Vec, - pub manifest_dir: PathBuf, - pub productions: HashMap, + pub schema_dir: PathBuf, + pub productions: IndexMap, } #[derive(Deserialize, Serialize, Clone, Debug)] #[serde(deny_unknown_fields)] -pub struct GrammarSection { +pub struct SchemaSection { pub title: String, pub path: String, - pub topics: Vec, + pub topics: Vec, } #[derive(Deserialize, Serialize, Clone, Debug)] #[serde(deny_unknown_fields)] -pub struct GrammarTopic { +pub struct SchemaTopic { pub title: String, pub path: String, pub productions: IndexMap, } -impl GrammarTopic { +impl SchemaTopic { // TODO(OmarTawfik): This method is definetely used. // Need to isolate and report the bug to the rustc team. #[allow(dead_code)] diff --git a/crates/codegen/schema/src/utils.rs b/crates/codegen/schema/src/utils.rs index a7a1cf23b0..7a65f12bbf 100644 --- a/crates/codegen/schema/src/utils.rs +++ b/crates/codegen/schema/src/utils.rs @@ -2,9 +2,9 @@ use std::collections::BTreeSet; use semver::Version; -use crate::types::grammar::Grammar; +use crate::types::schema::Schema; -impl Grammar { +impl Schema { pub fn collect_version_breaks<'a>(&'a self) -> BTreeSet { let mut version_breaks = BTreeSet::new(); version_breaks.insert(self.versions.first().cloned().unwrap()); diff --git a/crates/codegen/schema/src/validation/rules/manifest_paths.rs b/crates/codegen/schema/src/validation/rules/manifest_paths.rs index e3ca0dedd0..19cbc748fe 100644 --- a/crates/codegen/schema/src/validation/rules/manifest_paths.rs +++ b/crates/codegen/schema/src/validation/rules/manifest_paths.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use codegen_utils::errors::CodegenErrors; use crate::{ - types::grammar::GrammarTopic, + types::schema::SchemaTopic, validation::{ ast::{ files::ManifestFile, @@ -20,13 +20,13 @@ pub fn check(model: &Model, errors: &mut CodegenErrors) { } struct PathsChecker { - grammar_dir: PathBuf, + schema_dir: PathBuf, } impl PathsChecker { fn new(model: &Model) -> Self { return Self { - grammar_dir: model.manifest_file.path.parent().unwrap().to_owned(), + schema_dir: model.manifest_file.path.parent().unwrap().to_owned(), }; } } @@ -38,7 +38,7 @@ impl Visitor for PathsChecker { reporter: &mut Reporter, ) -> VisitorResponse { for section in &manifest_file.ast.value.sections { - let section_path = self.grammar_dir.join(§ion.path.value); + let section_path = self.schema_dir.join(§ion.path.value); if !section_path.exists() { reporter.report(§ion.path.cst_node, Errors::PathNotFound(section_path)); @@ -54,8 +54,8 @@ impl Visitor for PathsChecker { } for path in [ - topic_path.join(GrammarTopic::productions_file()), - topic_path.join(GrammarTopic::notes_file()), + topic_path.join(SchemaTopic::productions_file()), + topic_path.join(SchemaTopic::notes_file()), ] { if !path.exists() { reporter.report(&topic.path.cst_node, Errors::PathNotFound(path)); diff --git a/crates/codegen/spec/src/grammar.rs b/crates/codegen/spec/src/grammar.rs index 640ba55a96..c52e7246c6 100644 --- a/crates/codegen/spec/src/grammar.rs +++ b/crates/codegen/spec/src/grammar.rs @@ -1,20 +1,20 @@ use std::path::PathBuf; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use semver::Version; use crate::{markdown::MarkdownWriter, navigation::NavigationEntry, snippets::Snippets}; -pub fn generate_supported_versions_page(grammar: &Grammar) -> NavigationEntry { - let versions = &grammar.versions; - let version_breaks = grammar.collect_version_breaks(); +pub fn generate_supported_versions_page(schema: &Schema) -> NavigationEntry { + let versions = &schema.versions; + let version_breaks = schema.collect_version_breaks(); let mut page = MarkdownWriter::new(); page.write_header(1, "Supported Versions"); page.write_newline(); - page.write_text(&format!("This specification compiles information from {all_count} publicly released versions of {language}. Among which, {breaks_count} versions had syntax-related changes:", all_count = versions.len(), language = grammar.title, breaks_count = version_breaks.len())); + page.write_text(&format!("This specification compiles information from {all_count} publicly released versions of {language}. Among which, {breaks_count} versions had syntax-related changes:", all_count = versions.len(), language = schema.title, breaks_count = version_breaks.len())); page.write_newline(); for version in version_breaks { @@ -37,17 +37,17 @@ pub fn generate_supported_versions_page(grammar: &Grammar) -> NavigationEntry { } pub fn generate_grammar_dir( - grammar: &Grammar, + schema: &Schema, snippets: &Snippets, repo_root: &PathBuf, ) -> NavigationEntry { let mut pages = Vec::::new(); - for version in grammar.collect_version_breaks() { + for version in schema.collect_version_breaks() { pages.push(NavigationEntry::Page { title: format!("v{version}"), path: format!("v{version}"), - contents: generate_grammar_page(grammar, snippets, repo_root, &version), + contents: generate_grammar_page(schema, snippets, repo_root, &version), }); } @@ -59,7 +59,7 @@ pub fn generate_grammar_dir( } fn generate_grammar_page( - grammar: &Grammar, + schema: &Schema, snippets: &Snippets, repo_root: &PathBuf, version: &Version, @@ -68,7 +68,7 @@ fn generate_grammar_page( page.write_header(1, "Grammar"); - for section in &grammar.sections { + for section in &schema.sections { page.write_newline(); page.write_header(2, §ion.title); diff --git a/crates/codegen/spec/src/lib.rs b/crates/codegen/spec/src/lib.rs index 0b5f5787bf..40d8853e30 100644 --- a/crates/codegen/spec/src/lib.rs +++ b/crates/codegen/spec/src/lib.rs @@ -7,7 +7,7 @@ mod snippets; use std::path::PathBuf; use anyhow::Result; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use crate::{ @@ -17,11 +17,11 @@ use crate::{ snippets::Snippets, }; -pub trait GrammarSpecGeneratorExtensions { +pub trait SpecGeneratorExtensions { fn generate_spec(&self, codegen: &mut CodegenContext, output_dir: &PathBuf) -> Result<()>; } -impl GrammarSpecGeneratorExtensions for Grammar { +impl SpecGeneratorExtensions for Schema { fn generate_spec(&self, codegen: &mut CodegenContext, output_dir: &PathBuf) -> Result<()> { let snippets = Snippets::new(self, output_dir); snippets.write_files(codegen)?; diff --git a/crates/codegen/spec/src/reference.rs b/crates/codegen/spec/src/reference.rs index cb4399b4ad..fbcba91a3d 100644 --- a/crates/codegen/spec/src/reference.rs +++ b/crates/codegen/spec/src/reference.rs @@ -1,20 +1,20 @@ use std::path::PathBuf; -use codegen_schema::types::grammar::{Grammar, GrammarSection, GrammarTopic}; +use codegen_schema::types::schema::{Schema, SchemaSection, SchemaTopic}; use crate::{markdown::MarkdownWriter, navigation::NavigationEntry}; -pub fn generate_reference_dir(grammar: &Grammar, repo_root: &PathBuf) -> NavigationEntry { +pub fn generate_reference_dir(schema: &Schema, repo_root: &PathBuf) -> NavigationEntry { let mut sections = Vec::::new(); - for section in &grammar.sections { + for section in &schema.sections { let mut topics = Vec::::new(); for topic in §ion.topics { topics.push(NavigationEntry::Page { title: topic.title.to_owned(), path: topic.path.to_owned(), - contents: generate_topic_page(grammar, section, topic, repo_root), + contents: generate_topic_page(schema, section, topic, repo_root), }); } @@ -33,9 +33,9 @@ pub fn generate_reference_dir(grammar: &Grammar, repo_root: &PathBuf) -> Navigat } fn generate_topic_page( - grammar: &Grammar, - section: &GrammarSection, - topic: &GrammarTopic, + schema: &Schema, + section: &SchemaSection, + topic: &SchemaTopic, repo_root: &PathBuf, ) -> String { let mut page = MarkdownWriter::new(); @@ -45,11 +45,11 @@ fn generate_topic_page( page.write_newline(); page.write_snippet( repo_root, - &grammar - .manifest_dir + &schema + .schema_dir .join(§ion.path) .join(&topic.path) - .join(GrammarTopic::notes_file()), + .join(SchemaTopic::notes_file()), ); return page.to_string(); diff --git a/crates/codegen/spec/src/snippets.rs b/crates/codegen/spec/src/snippets.rs index 2f5402f3d9..9cb539dcf9 100644 --- a/crates/codegen/spec/src/snippets.rs +++ b/crates/codegen/spec/src/snippets.rs @@ -3,8 +3,8 @@ use std::path::PathBuf; use anyhow::Result; use codegen_ebnf::EbnfSerializer; use codegen_schema::types::{ - grammar::{Grammar, GrammarSection, GrammarTopic}, production::{Production, ProductionRef, VersionMap}, + schema::{Schema, SchemaSection, SchemaTopic}, }; use codegen_utils::context::CodegenContext; use inflector::Inflector; @@ -13,21 +13,18 @@ use semver::Version; use crate::markdown::MarkdownWriter; pub struct Snippets<'context> { - grammar: &'context Grammar, + schema: &'context Schema, output_dir: &'context PathBuf, } impl<'context> Snippets<'context> { - pub fn new(grammar: &'context Grammar, output_dir: &'context PathBuf) -> Self { - return Self { - grammar, - output_dir, - }; + pub fn new(schema: &'context Schema, output_dir: &'context PathBuf) -> Self { + return Self { schema, output_dir }; } pub fn write_files(&self, codegen: &mut CodegenContext) -> Result<()> { - let last_version = self.grammar.versions.last().unwrap(); - for production in self.grammar.productions.values() { + let last_version = self.schema.versions.last().unwrap(); + for production in self.schema.productions.values() { let versions = match production.versions() { None => vec![last_version], Some(versions) => versions, @@ -97,14 +94,14 @@ impl<'context> Snippets<'context> { let class = "slang-ebnf"; // used to select code blocks via JS during runtime let id = production.name(); // used for navigation (generarating URL hashes) - let contents = &EbnfSerializer::serialize_version(self.grammar, production, version)?; + let contents = &EbnfSerializer::serialize_version(self.schema, production, version)?; snippet.write_code_block(language, class, id, contents); return Some(snippet.to_string()); } - fn locate_production(&self, name: &str) -> (&GrammarSection, &GrammarTopic) { - for section in &self.grammar.sections { + fn locate_production(&self, name: &str) -> (&SchemaSection, &SchemaTopic) { + for section in &self.schema.sections { for topic in §ion.topics { if topic.productions.contains_key(name) { return (section, topic); diff --git a/crates/codegen/syntax/src/code_generator.rs b/crates/codegen/syntax/src/code_generator.rs index 9b3b23990d..6045008264 100644 --- a/crates/codegen/syntax/src/code_generator.rs +++ b/crates/codegen/syntax/src/code_generator.rs @@ -3,7 +3,7 @@ use std::{ path::PathBuf, }; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use inflector::Inflector; use proc_macro2::{Ident, TokenStream}; @@ -14,9 +14,9 @@ use semver::Version; pub struct VersionedFunctionBody(BTreeMap>); impl VersionedFunctionBody { - fn new(first_grammar_version: &Version) -> Self { + fn new(first_schema_version: &Version) -> Self { let mut versions = BTreeMap::new(); - versions.insert(first_grammar_version.clone(), None); + versions.insert(first_schema_version.clone(), None); Self(versions) } @@ -128,9 +128,9 @@ pub struct CodeGenerator { } impl CodeGenerator { - pub fn new(grammar: &Grammar) -> Self { + pub fn new(schema: &Schema) -> Self { Self { - first_version: grammar.versions.first().unwrap().clone(), + first_version: schema.versions.first().unwrap().clone(), token_kinds: Default::default(), scanners: Default::default(), rule_kinds: Default::default(), diff --git a/crates/codegen/syntax/src/combinator_context.rs b/crates/codegen/syntax/src/combinator_context.rs index 0dbd481c33..7500a2e2e8 100644 --- a/crates/codegen/syntax/src/combinator_context.rs +++ b/crates/codegen/syntax/src/combinator_context.rs @@ -1,7 +1,7 @@ use std::cell::RefCell; use std::collections::BTreeMap; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use semver::Version; use typed_arena::Arena; @@ -9,7 +9,7 @@ use super::combinator_node::CombinatorNode; use super::combinator_tree::CombinatorTree; pub struct CombinatorContext<'context> { - pub grammar: &'context Grammar, + pub schema: &'context Schema, pub version: Version, pub trees_by_name: RefCell>>, tree_arena: Arena>, @@ -17,9 +17,9 @@ pub struct CombinatorContext<'context> { } impl<'context> CombinatorContext<'context> { - pub fn new(grammar: &'context Grammar, version: Version) -> Self { + pub fn new(schema: &'context Schema, version: Version) -> Self { CombinatorContext { - grammar, + schema, version, trees_by_name: Default::default(), tree_arena: Arena::new(), diff --git a/crates/codegen/syntax/src/combinator_tree.rs b/crates/codegen/syntax/src/combinator_tree.rs index edd98e1762..4d0dce7ea1 100644 --- a/crates/codegen/syntax/src/combinator_tree.rs +++ b/crates/codegen/syntax/src/combinator_tree.rs @@ -51,7 +51,7 @@ impl<'context> CombinatorTree<'context> { } pub fn add_to_generated_code(&self, code: &mut CodeGenerator) { - let first_version = self.context.grammar.versions.first().unwrap(); + let first_version = self.context.schema.versions.first().unwrap(); let version = &self.context.version; let matches_version = match self.production.versions() { Some(versions) => versions.contains(&version), @@ -103,7 +103,7 @@ impl<'context> CombinatorTree<'context> { } if let Some(ebnf) = EbnfSerializer::serialize_version( - self.context.grammar, + self.context.schema, &self.production, &self.context.version, ) { diff --git a/crates/codegen/syntax/src/lib.rs b/crates/codegen/syntax/src/lib.rs index daf802fc22..63966ad6f9 100644 --- a/crates/codegen/syntax/src/lib.rs +++ b/crates/codegen/syntax/src/lib.rs @@ -4,11 +4,11 @@ mod combinator_context; mod combinator_node; mod combinator_tree; mod first_set; -mod grammar; mod rust_lib_code_generator; +mod schema; mod to_parser_code; mod to_scanner_code; mod trie; mod typescript_lib_code_generator; -pub use grammar::GrammarParserGeneratorExtensions; +pub use schema::SyntaxGeneratorExtensions; diff --git a/crates/codegen/syntax/src/rust_lib_code_generator.rs b/crates/codegen/syntax/src/rust_lib_code_generator.rs index 092cce14c8..b960b03e7e 100644 --- a/crates/codegen/syntax/src/rust_lib_code_generator.rs +++ b/crates/codegen/syntax/src/rust_lib_code_generator.rs @@ -1,7 +1,7 @@ use quote::quote; use std::path::PathBuf; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use super::code_generator::CodeGenerator; @@ -9,7 +9,7 @@ use super::code_generator::CodeGenerator; impl CodeGenerator { pub fn write_rust_lib_sources( &self, - grammar: &Grammar, + schema: &Schema, codegen: &mut CodegenContext, output_dir: &PathBuf, ) { @@ -62,7 +62,7 @@ impl CodeGenerator { #[derive(thiserror::Error, Debug)] pub enum Error {{ - #[error(\"Invalid {grammar_title} language version '{{0}}'.\")] + #[error(\"Invalid {schema_title} language version '{{0}}'.\")] InvalidLanguageVersion(Version), }} @@ -90,7 +90,7 @@ impl CodeGenerator { }}; output.unwrap_or_else(|| {{ - let message = format!(\"ProductionKind {{production_kind}} is not valid in this version of {grammar_title}\"); + let message = format!(\"ProductionKind {{production_kind}} is not valid in this version of {schema_title}\"); ParseOutput {{ parse_tree: None, errors: vec![ParseError::new(Default::default(), message)] @@ -107,9 +107,9 @@ impl CodeGenerator { ) .unwrap(), version_flag_declarations = self.version_flag_declarations(), - grammar_title = &grammar.title, + schema_title = &schema.title, versions_array = { - let versions = grammar.versions.iter().map(|v| v.to_string()); + let versions = schema.versions.iter().map(|v| v.to_string()); quote! { static VERSIONS: &'static [&'static str] = &[ #(#versions),* ]; } }, version_flag_initializers = self.version_flag_initializers(), diff --git a/crates/codegen/syntax/src/grammar.rs b/crates/codegen/syntax/src/schema.rs similarity index 91% rename from crates/codegen/syntax/src/grammar.rs rename to crates/codegen/syntax/src/schema.rs index 19a83fb40b..b67ce3a99f 100644 --- a/crates/codegen/syntax/src/grammar.rs +++ b/crates/codegen/syntax/src/schema.rs @@ -1,11 +1,11 @@ -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use super::code_generator::CodeGenerator; use super::combinator_context::CombinatorContext; use super::combinator_tree::CombinatorTree; -pub trait GrammarParserGeneratorExtensions { +pub trait SyntaxGeneratorExtensions { fn generate_rust_lib_sources( &self, context: &mut CodegenContext, @@ -18,11 +18,11 @@ pub trait GrammarParserGeneratorExtensions { ); } -trait PrivateGrammarParserGeneratorExtensions { +trait PrivateSyntaxGeneratorExtensions { fn create_code_generator(&self) -> CodeGenerator; } -impl GrammarParserGeneratorExtensions for Grammar { +impl SyntaxGeneratorExtensions for Schema { fn generate_rust_lib_sources( &self, context: &mut CodegenContext, @@ -42,7 +42,7 @@ impl GrammarParserGeneratorExtensions for Grammar { } } -impl PrivateGrammarParserGeneratorExtensions for Grammar { +impl PrivateSyntaxGeneratorExtensions for Schema { fn create_code_generator(&self) -> CodeGenerator { let version_breaks = self.collect_version_breaks(); diff --git a/crates/codegen/syntax/src/typescript_lib_code_generator.rs b/crates/codegen/syntax/src/typescript_lib_code_generator.rs index 7d882c3c02..bd0a1d760a 100644 --- a/crates/codegen/syntax/src/typescript_lib_code_generator.rs +++ b/crates/codegen/syntax/src/typescript_lib_code_generator.rs @@ -1,7 +1,7 @@ use quote::quote; use std::path::PathBuf; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use super::code_generator::CodeGenerator; @@ -9,7 +9,7 @@ use super::code_generator::CodeGenerator; impl CodeGenerator { pub fn write_typescript_lib_sources( &self, - grammar: &Grammar, + schema: &Schema, codegen: &mut CodegenContext, output_dir: &PathBuf, ) { @@ -73,7 +73,7 @@ impl CodeGenerator { version, }} }} else {{ - panic!(\"Invalid {grammar_title} language version: {{version}}\"); + panic!(\"Invalid {schema_title} language version: {{version}}\"); }} }} @@ -88,7 +88,7 @@ impl CodeGenerator { match production_kind {{ {scanner_invocations}, {parser_invocations}, - }}.expect(&format!(\"Production {{production_kind:?}} is not valid in this version of {grammar_title}\")) + }}.expect(&format!(\"Production {{production_kind:?}} is not valid in this version of {schema_title}\")) }} }} ", @@ -101,11 +101,11 @@ impl CodeGenerator { .unwrap(), version_flag_declarations = self.version_flag_declarations(), versions_array = { - let versions = grammar.versions.iter().map(|v| v.to_string()); + let versions = schema.versions.iter().map(|v| v.to_string()); quote! { static VERSIONS: &'static [&'static str] = &[ #(#versions),* ]; } }, version_flag_initializers = self.version_flag_initializers(), - grammar_title = &grammar.title, + schema_title = &schema.title, scanner_invocations = self.scanner_invocations(), parser_invocations = self.parser_invocations(), ); diff --git a/crates/codegen/testing/src/cst_output.rs b/crates/codegen/testing/src/cst_output.rs index 1777a3107e..adcf35b4b6 100644 --- a/crates/codegen/testing/src/cst_output.rs +++ b/crates/codegen/testing/src/cst_output.rs @@ -4,19 +4,19 @@ use std::{ }; use anyhow::{bail, Context, Result}; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use walkdir::WalkDir; pub fn generate_cst_output_tests( - grammar: &Grammar, + schema: &Schema, codegen: &mut CodegenContext, data_dir: &PathBuf, output_dir: &PathBuf, ) -> Result<()> { let mod_file_path = output_dir.join("mod.rs"); let parser_tests = &collect_parser_tests(codegen, data_dir)?; - generate_mod_file(grammar, codegen, &mod_file_path, parser_tests)?; + generate_mod_file(schema, codegen, &mod_file_path, parser_tests)?; for (parser_name, test_names) in parser_tests { generate_unit_test_file( @@ -75,7 +75,7 @@ fn collect_parser_tests( } fn generate_mod_file( - grammar: &Grammar, + schema: &Schema, codegen: &mut CodegenContext, mod_file_path: &PathBuf, parser_tests: &BTreeMap>, @@ -85,7 +85,7 @@ fn generate_mod_file( .map(|parser_name| format!("#[allow(non_snake_case)] mod {parser_name};")) .collect::(); - let version_breaks = grammar.collect_version_breaks(); + let version_breaks = schema.collect_version_breaks(); let version_breaks_len = version_breaks.len(); let version_breaks_str = version_breaks .iter() diff --git a/crates/codegen/testing/src/lib.rs b/crates/codegen/testing/src/lib.rs index fde31e7b59..ecbcb6589b 100644 --- a/crates/codegen/testing/src/lib.rs +++ b/crates/codegen/testing/src/lib.rs @@ -3,12 +3,12 @@ mod cst_output; use std::path::PathBuf; use anyhow::Result; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; use crate::cst_output::generate_cst_output_tests; -pub trait GrammarTestingGeneratorExtensions { +pub trait TestingGeneratorExtensions { fn generate_cst_output_tests( &self, codegen: &mut CodegenContext, @@ -17,7 +17,7 @@ pub trait GrammarTestingGeneratorExtensions { ) -> Result<()>; } -impl GrammarTestingGeneratorExtensions for Grammar { +impl TestingGeneratorExtensions for Schema { fn generate_cst_output_tests( &self, codegen: &mut CodegenContext, diff --git a/crates/codegen/utils/src/context.rs b/crates/codegen/utils/src/context.rs index df685d3d8a..8ae6157afc 100644 --- a/crates/codegen/utils/src/context.rs +++ b/crates/codegen/utils/src/context.rs @@ -43,6 +43,8 @@ impl CodegenContext { } pub fn track_input_dir(&mut self, path: &PathBuf) { + std::env::var("OUT_DIR").expect("This function can only be called from build scripts"); + // Skip if same path (or a parent) is already marked for input_dir in &self.input_dirs { if path.starts_with(input_dir) { diff --git a/crates/solidity/inputs/schema/build.rs b/crates/solidity/inputs/schema/build.rs index 82b5735008..4ae08ccd69 100644 --- a/crates/solidity/inputs/schema/build.rs +++ b/crates/solidity/inputs/schema/build.rs @@ -1,24 +1,24 @@ use std::path::PathBuf; use anyhow::Result; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use codegen_utils::context::CodegenContext; fn main() -> Result<()> { return CodegenContext::with_context(|codegen| { - let manifest_dir = codegen + let schema_dir = codegen .repo_root - .join("crates/solidity/inputs/schema/grammar"); + .join("crates/solidity/inputs/schema/definition"); // Rebuild if input files are added/removed - codegen.track_input_dir(&manifest_dir); + codegen.track_input_dir(&schema_dir); - let grammar = Grammar::compile(codegen, manifest_dir)?; + let schema = Schema::compile(codegen, schema_dir)?; let mut buffer = Vec::new(); - bson::to_document(&grammar)?.to_writer(&mut buffer)?; + bson::to_document(&schema)?.to_writer(&mut buffer)?; - let output_path = PathBuf::from(std::env::var("OUT_DIR")?).join("generated/grammar.bin"); + let output_path = PathBuf::from(std::env::var("OUT_DIR")?).join("generated/schema.bin"); std::fs::create_dir_all(output_path.parent().unwrap())?; std::fs::write(&output_path, &buffer)?; diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/01-license-specifiers/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/01-license-specifiers/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/01-license-specifiers/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/01-license-specifiers/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/01-license-specifiers/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/01-license-specifiers/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/01-license-specifiers/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/01-license-specifiers/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/02-source-unit/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/02-source-unit/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/02-source-unit/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/02-source-unit/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/02-source-unit/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/02-source-unit/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/02-source-unit/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/02-source-unit/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/03-pragmas/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/03-pragmas/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/03-pragmas/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/03-pragmas/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/03-pragmas/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/03-pragmas/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/03-pragmas/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/03-pragmas/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/04-imports/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/04-imports/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/04-imports/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/04-imports/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/04-imports/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/04-imports/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/04-imports/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/04-imports/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/05-trivia/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/05-trivia/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/05-trivia/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/05-trivia/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/05-trivia/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/05-trivia/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/05-trivia/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/05-trivia/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/06-nat-spec-format/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/06-nat-spec-format/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/06-nat-spec-format/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/06-nat-spec-format/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/06-nat-spec-format/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/06-nat-spec-format/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/06-nat-spec-format/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/06-nat-spec-format/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/07-keywords/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/07-keywords/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/07-keywords/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/07-keywords/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/07-keywords/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/07-keywords/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/07-keywords/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/07-keywords/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/08-punctuation/notes.md b/crates/solidity/inputs/schema/definition/01-file-structure/08-punctuation/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/08-punctuation/notes.md rename to crates/solidity/inputs/schema/definition/01-file-structure/08-punctuation/notes.md diff --git a/crates/solidity/inputs/schema/grammar/01-file-structure/08-punctuation/productions.yml b/crates/solidity/inputs/schema/definition/01-file-structure/08-punctuation/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/01-file-structure/08-punctuation/productions.yml rename to crates/solidity/inputs/schema/definition/01-file-structure/08-punctuation/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/01-contracts/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/01-contracts/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/01-contracts/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/01-contracts/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/01-contracts/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/01-contracts/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/01-contracts/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/01-contracts/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/02-interfaces/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/02-interfaces/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/02-interfaces/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/02-interfaces/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/02-interfaces/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/02-interfaces/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/02-interfaces/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/02-interfaces/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/03-libraries/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/03-libraries/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/03-libraries/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/03-libraries/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/03-libraries/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/03-libraries/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/03-libraries/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/03-libraries/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/04-structs/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/04-structs/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/04-structs/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/04-structs/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/04-structs/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/04-structs/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/04-structs/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/04-structs/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/05-enums/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/05-enums/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/05-enums/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/05-enums/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/05-enums/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/05-enums/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/05-enums/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/05-enums/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/06-constants/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/06-constants/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/06-constants/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/06-constants/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/06-constants/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/06-constants/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/06-constants/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/06-constants/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/07-state-variables/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/07-state-variables/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/07-state-variables/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/07-state-variables/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/07-state-variables/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/07-state-variables/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/07-state-variables/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/07-state-variables/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/08-functions/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/08-functions/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/08-functions/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/08-functions/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/08-functions/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/08-functions/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/08-functions/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/08-functions/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/09-modifiers/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/09-modifiers/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/09-modifiers/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/09-modifiers/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/09-modifiers/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/09-modifiers/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/09-modifiers/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/09-modifiers/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/10-events/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/10-events/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/10-events/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/10-events/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/10-events/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/10-events/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/10-events/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/10-events/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/11-user-defined-value-types/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/11-user-defined-value-types/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/11-user-defined-value-types/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/11-user-defined-value-types/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/11-user-defined-value-types/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/11-user-defined-value-types/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/11-user-defined-value-types/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/11-user-defined-value-types/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/12-errors/notes.md b/crates/solidity/inputs/schema/definition/02-definitions/12-errors/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/12-errors/notes.md rename to crates/solidity/inputs/schema/definition/02-definitions/12-errors/notes.md diff --git a/crates/solidity/inputs/schema/grammar/02-definitions/12-errors/productions.yml b/crates/solidity/inputs/schema/definition/02-definitions/12-errors/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/02-definitions/12-errors/productions.yml rename to crates/solidity/inputs/schema/definition/02-definitions/12-errors/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/03-types/01-advanced-types/notes.md b/crates/solidity/inputs/schema/definition/03-types/01-advanced-types/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/03-types/01-advanced-types/notes.md rename to crates/solidity/inputs/schema/definition/03-types/01-advanced-types/notes.md diff --git a/crates/solidity/inputs/schema/grammar/03-types/01-advanced-types/productions.yml b/crates/solidity/inputs/schema/definition/03-types/01-advanced-types/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/03-types/01-advanced-types/productions.yml rename to crates/solidity/inputs/schema/definition/03-types/01-advanced-types/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/03-types/02-elementary-types/notes.md b/crates/solidity/inputs/schema/definition/03-types/02-elementary-types/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/03-types/02-elementary-types/notes.md rename to crates/solidity/inputs/schema/definition/03-types/02-elementary-types/notes.md diff --git a/crates/solidity/inputs/schema/grammar/03-types/02-elementary-types/productions.yml b/crates/solidity/inputs/schema/definition/03-types/02-elementary-types/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/03-types/02-elementary-types/productions.yml rename to crates/solidity/inputs/schema/definition/03-types/02-elementary-types/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/04-statements/01-blocks/notes.md b/crates/solidity/inputs/schema/definition/04-statements/01-blocks/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/01-blocks/notes.md rename to crates/solidity/inputs/schema/definition/04-statements/01-blocks/notes.md diff --git a/crates/solidity/inputs/schema/grammar/04-statements/01-blocks/productions.yml b/crates/solidity/inputs/schema/definition/04-statements/01-blocks/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/01-blocks/productions.yml rename to crates/solidity/inputs/schema/definition/04-statements/01-blocks/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/04-statements/02-declaration-statements/notes.md b/crates/solidity/inputs/schema/definition/04-statements/02-declaration-statements/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/02-declaration-statements/notes.md rename to crates/solidity/inputs/schema/definition/04-statements/02-declaration-statements/notes.md diff --git a/crates/solidity/inputs/schema/grammar/04-statements/02-declaration-statements/productions.yml b/crates/solidity/inputs/schema/definition/04-statements/02-declaration-statements/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/02-declaration-statements/productions.yml rename to crates/solidity/inputs/schema/definition/04-statements/02-declaration-statements/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/04-statements/03-control-statements/notes.md b/crates/solidity/inputs/schema/definition/04-statements/03-control-statements/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/03-control-statements/notes.md rename to crates/solidity/inputs/schema/definition/04-statements/03-control-statements/notes.md diff --git a/crates/solidity/inputs/schema/grammar/04-statements/03-control-statements/productions.yml b/crates/solidity/inputs/schema/definition/04-statements/03-control-statements/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/03-control-statements/productions.yml rename to crates/solidity/inputs/schema/definition/04-statements/03-control-statements/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/04-statements/04-error-handling/notes.md b/crates/solidity/inputs/schema/definition/04-statements/04-error-handling/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/04-error-handling/notes.md rename to crates/solidity/inputs/schema/definition/04-statements/04-error-handling/notes.md diff --git a/crates/solidity/inputs/schema/grammar/04-statements/04-error-handling/productions.yml b/crates/solidity/inputs/schema/definition/04-statements/04-error-handling/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/04-statements/04-error-handling/productions.yml rename to crates/solidity/inputs/schema/definition/04-statements/04-error-handling/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/01-base-expressions/notes.md b/crates/solidity/inputs/schema/definition/05-expressions/01-base-expressions/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/01-base-expressions/notes.md rename to crates/solidity/inputs/schema/definition/05-expressions/01-base-expressions/notes.md diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/01-base-expressions/productions.yml b/crates/solidity/inputs/schema/definition/05-expressions/01-base-expressions/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/01-base-expressions/productions.yml rename to crates/solidity/inputs/schema/definition/05-expressions/01-base-expressions/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/02-primary-expressions/notes.md b/crates/solidity/inputs/schema/definition/05-expressions/02-primary-expressions/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/02-primary-expressions/notes.md rename to crates/solidity/inputs/schema/definition/05-expressions/02-primary-expressions/notes.md diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/02-primary-expressions/productions.yml b/crates/solidity/inputs/schema/definition/05-expressions/02-primary-expressions/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/02-primary-expressions/productions.yml rename to crates/solidity/inputs/schema/definition/05-expressions/02-primary-expressions/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/03-numbers/notes.md b/crates/solidity/inputs/schema/definition/05-expressions/03-numbers/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/03-numbers/notes.md rename to crates/solidity/inputs/schema/definition/05-expressions/03-numbers/notes.md diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/03-numbers/productions.yml b/crates/solidity/inputs/schema/definition/05-expressions/03-numbers/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/03-numbers/productions.yml rename to crates/solidity/inputs/schema/definition/05-expressions/03-numbers/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/04-strings/notes.md b/crates/solidity/inputs/schema/definition/05-expressions/04-strings/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/04-strings/notes.md rename to crates/solidity/inputs/schema/definition/05-expressions/04-strings/notes.md diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/04-strings/productions.yml b/crates/solidity/inputs/schema/definition/05-expressions/04-strings/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/04-strings/productions.yml rename to crates/solidity/inputs/schema/definition/05-expressions/04-strings/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/05-identifiers/notes.md b/crates/solidity/inputs/schema/definition/05-expressions/05-identifiers/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/05-identifiers/notes.md rename to crates/solidity/inputs/schema/definition/05-expressions/05-identifiers/notes.md diff --git a/crates/solidity/inputs/schema/grammar/05-expressions/05-identifiers/productions.yml b/crates/solidity/inputs/schema/definition/05-expressions/05-identifiers/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/05-expressions/05-identifiers/productions.yml rename to crates/solidity/inputs/schema/definition/05-expressions/05-identifiers/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/06-yul/01-assembly-block/notes.md b/crates/solidity/inputs/schema/definition/06-yul/01-assembly-block/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/01-assembly-block/notes.md rename to crates/solidity/inputs/schema/definition/06-yul/01-assembly-block/notes.md diff --git a/crates/solidity/inputs/schema/grammar/06-yul/01-assembly-block/productions.yml b/crates/solidity/inputs/schema/definition/06-yul/01-assembly-block/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/01-assembly-block/productions.yml rename to crates/solidity/inputs/schema/definition/06-yul/01-assembly-block/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/06-yul/02-yul-statements/notes.md b/crates/solidity/inputs/schema/definition/06-yul/02-yul-statements/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/02-yul-statements/notes.md rename to crates/solidity/inputs/schema/definition/06-yul/02-yul-statements/notes.md diff --git a/crates/solidity/inputs/schema/grammar/06-yul/02-yul-statements/productions.yml b/crates/solidity/inputs/schema/definition/06-yul/02-yul-statements/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/02-yul-statements/productions.yml rename to crates/solidity/inputs/schema/definition/06-yul/02-yul-statements/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/06-yul/03-yul-expressions/notes.md b/crates/solidity/inputs/schema/definition/06-yul/03-yul-expressions/notes.md similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/03-yul-expressions/notes.md rename to crates/solidity/inputs/schema/definition/06-yul/03-yul-expressions/notes.md diff --git a/crates/solidity/inputs/schema/grammar/06-yul/03-yul-expressions/productions.yml b/crates/solidity/inputs/schema/definition/06-yul/03-yul-expressions/productions.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/06-yul/03-yul-expressions/productions.yml rename to crates/solidity/inputs/schema/definition/06-yul/03-yul-expressions/productions.yml diff --git a/crates/solidity/inputs/schema/grammar/manifest.yml b/crates/solidity/inputs/schema/definition/manifest.yml similarity index 100% rename from crates/solidity/inputs/schema/grammar/manifest.yml rename to crates/solidity/inputs/schema/definition/manifest.yml diff --git a/crates/solidity/inputs/schema/src/lib.rs b/crates/solidity/inputs/schema/src/lib.rs index e7d4fb8e2e..aabb347309 100644 --- a/crates/solidity/inputs/schema/src/lib.rs +++ b/crates/solidity/inputs/schema/src/lib.rs @@ -1,18 +1,22 @@ use std::path::PathBuf; use anyhow::Result; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; -pub trait SolidityGrammarExtensions { - fn load_solidity() -> Result; +pub trait SoliditySchemaExtensions { + fn load_solidity() -> Result; } -impl SolidityGrammarExtensions for Grammar { - fn load_solidity() -> Result { +impl SoliditySchemaExtensions for Schema { + /// We compile the schema only once, and then expose it here to all downstream crates. + /// This ensures that: + /// 1. Expensive parsing and validation is done only once. + /// 2. Errors are reported only once, instead of repeating for every crate. + fn load_solidity() -> Result { let bin_path = PathBuf::from(env!("SLANG_SOLIDITY_INPUT_SCHEMA_BIN")); let buffer = std::fs::read(&bin_path)?; - let grammar: Grammar = bson::from_slice(&buffer)?; + let schema: Schema = bson::from_slice(&buffer)?; - return Ok(grammar); + return Ok(schema); } } diff --git a/crates/solidity/outputs/cargo/build/build.rs b/crates/solidity/outputs/cargo/build/build.rs index 5a03e975a7..679509cf2c 100644 --- a/crates/solidity/outputs/cargo/build/build.rs +++ b/crates/solidity/outputs/cargo/build/build.rs @@ -1,18 +1,18 @@ use anyhow::Result; -use codegen_schema::types::grammar::Grammar; -use codegen_syntax::GrammarParserGeneratorExtensions; +use codegen_schema::types::schema::Schema; +use codegen_syntax::SyntaxGeneratorExtensions; use codegen_utils::context::CodegenContext; -use solidity_schema::SolidityGrammarExtensions; +use solidity_schema::SoliditySchemaExtensions; fn main() -> Result<()> { return CodegenContext::with_context(|codegen| { - let grammar = Grammar::load_solidity()?; + let schema = Schema::load_solidity()?; let output_dir = codegen .repo_root .join("crates/solidity/outputs/cargo/crate/src/generated"); - grammar.generate_rust_lib_sources(codegen, &output_dir); + schema.generate_rust_lib_sources(codegen, &output_dir); return Ok(()); }); } diff --git a/crates/solidity/outputs/cargo/tests/build.rs b/crates/solidity/outputs/cargo/tests/build.rs index 29fa8dd314..adcc297671 100644 --- a/crates/solidity/outputs/cargo/tests/build.rs +++ b/crates/solidity/outputs/cargo/tests/build.rs @@ -1,14 +1,14 @@ use anyhow::Result; -use codegen_schema::types::grammar::Grammar; -use codegen_testing::GrammarTestingGeneratorExtensions; +use codegen_schema::types::schema::Schema; +use codegen_testing::TestingGeneratorExtensions; use codegen_utils::context::CodegenContext; -use solidity_schema::SolidityGrammarExtensions; +use solidity_schema::SoliditySchemaExtensions; fn main() -> Result<()> { return CodegenContext::with_context(|codegen| { - let grammar = Grammar::load_solidity()?; + let schema = Schema::load_solidity()?; - grammar.generate_cst_output_tests( + schema.generate_cst_output_tests( codegen, &codegen .repo_root diff --git a/crates/solidity/outputs/npm/build/build.rs b/crates/solidity/outputs/npm/build/build.rs index 444ce7093c..54bcc40109 100644 --- a/crates/solidity/outputs/npm/build/build.rs +++ b/crates/solidity/outputs/npm/build/build.rs @@ -1,18 +1,18 @@ use anyhow::Result; -use codegen_schema::types::grammar::Grammar; -use codegen_syntax::GrammarParserGeneratorExtensions; +use codegen_schema::types::schema::Schema; +use codegen_syntax::SyntaxGeneratorExtensions; use codegen_utils::context::CodegenContext; -use solidity_schema::SolidityGrammarExtensions; +use solidity_schema::SoliditySchemaExtensions; fn main() -> Result<()> { return CodegenContext::with_context(|codegen| { - let grammar = Grammar::load_solidity()?; + let schema = Schema::load_solidity()?; let output_dir = codegen .repo_root .join("crates/solidity/outputs/npm/crate/src/generated"); - grammar.generate_typescript_lib_sources(codegen, &output_dir); + schema.generate_typescript_lib_sources(codegen, &output_dir); return Ok(()); }); diff --git a/crates/solidity/outputs/spec/build.rs b/crates/solidity/outputs/spec/build.rs index 9e20cb54c0..fa9d5a3e60 100644 --- a/crates/solidity/outputs/spec/build.rs +++ b/crates/solidity/outputs/spec/build.rs @@ -1,16 +1,16 @@ use anyhow::Result; -use codegen_schema::types::grammar::Grammar; -use codegen_spec::GrammarSpecGeneratorExtensions; +use codegen_schema::types::schema::Schema; +use codegen_spec::SpecGeneratorExtensions; use codegen_utils::context::CodegenContext; -use solidity_schema::SolidityGrammarExtensions; +use solidity_schema::SoliditySchemaExtensions; fn main() -> Result<()> { return CodegenContext::with_context(|codegen| { - let grammar = Grammar::load_solidity()?; + let schema = Schema::load_solidity()?; let output_dir = codegen .repo_root .join("crates/solidity/outputs/spec/generated"); - return grammar.generate_spec(codegen, &output_dir); + return schema.generate_spec(codegen, &output_dir); }); } diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/01-license-specifiers/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/01-license-specifiers/index.md index a80d8df529..8245e0bde6 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/01-license-specifiers/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/01-license-specifiers/index.md @@ -2,4 +2,4 @@ # 1.1. License Specifiers ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/01-license-specifiers/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/01-license-specifiers/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/02-source-unit/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/02-source-unit/index.md index c9296d5fa7..987a036bcb 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/02-source-unit/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/02-source-unit/index.md @@ -2,4 +2,4 @@ # 1.2. Source Unit ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/02-source-unit/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/02-source-unit/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/03-pragmas/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/03-pragmas/index.md index 26dd60da53..8a151c6c9c 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/03-pragmas/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/03-pragmas/index.md @@ -2,4 +2,4 @@ # 1.3. Pragmas ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/03-pragmas/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/03-pragmas/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/04-imports/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/04-imports/index.md index 5bdbeae6ea..dc8d375785 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/04-imports/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/04-imports/index.md @@ -2,4 +2,4 @@ # 1.4. Imports ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/04-imports/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/04-imports/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/05-trivia/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/05-trivia/index.md index 7104b42ed4..5c0b07c507 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/05-trivia/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/05-trivia/index.md @@ -2,4 +2,4 @@ # 1.5. Trivia ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/05-trivia/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/05-trivia/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/06-nat-spec-format/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/06-nat-spec-format/index.md index 536a80f232..7b1964b686 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/06-nat-spec-format/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/06-nat-spec-format/index.md @@ -2,4 +2,4 @@ # 1.6. NatSpec Format ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/06-nat-spec-format/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/06-nat-spec-format/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/07-keywords/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/07-keywords/index.md index 7e74ffa36c..3ad4111abf 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/07-keywords/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/07-keywords/index.md @@ -2,4 +2,4 @@ # 1.7. Keywords ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/07-keywords/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/07-keywords/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/08-punctuation/index.md b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/08-punctuation/index.md index cd7cb92fde..54300239cd 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/08-punctuation/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/01-file-structure/08-punctuation/index.md @@ -2,4 +2,4 @@ # 1.8 Punctuation ---8<-- "crates/solidity/inputs/schema/grammar/01-file-structure/08-punctuation/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/01-file-structure/08-punctuation/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/01-contracts/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/01-contracts/index.md index 9bf950fca4..1c8eda7ae0 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/01-contracts/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/01-contracts/index.md @@ -2,4 +2,4 @@ # 2.1. Contracts ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/01-contracts/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/01-contracts/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/02-interfaces/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/02-interfaces/index.md index 05c8369bfe..3b2bfc2bca 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/02-interfaces/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/02-interfaces/index.md @@ -2,4 +2,4 @@ # 2.2. Interfaces ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/02-interfaces/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/02-interfaces/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/03-libraries/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/03-libraries/index.md index 3105529267..47b8faac20 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/03-libraries/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/03-libraries/index.md @@ -2,4 +2,4 @@ # 2.3. Libraries ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/03-libraries/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/03-libraries/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/04-structs/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/04-structs/index.md index 25f6c43113..55df9c6497 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/04-structs/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/04-structs/index.md @@ -2,4 +2,4 @@ # 2.4. Structs ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/04-structs/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/04-structs/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/05-enums/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/05-enums/index.md index c8e5d72a83..da864e51d4 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/05-enums/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/05-enums/index.md @@ -2,4 +2,4 @@ # 2.5. Enums ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/05-enums/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/05-enums/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/06-constants/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/06-constants/index.md index 0b03d09787..34ab230cc2 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/06-constants/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/06-constants/index.md @@ -2,4 +2,4 @@ # 2.6. Constants ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/06-constants/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/06-constants/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/07-state-variables/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/07-state-variables/index.md index 12c0fa77f4..5b54db5d5a 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/07-state-variables/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/07-state-variables/index.md @@ -2,4 +2,4 @@ # 2.7. State Variables ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/07-state-variables/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/07-state-variables/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/08-functions/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/08-functions/index.md index 538812460c..8dc231bc18 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/08-functions/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/08-functions/index.md @@ -2,4 +2,4 @@ # 2.8. Functions ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/08-functions/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/08-functions/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/09-modifiers/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/09-modifiers/index.md index 9876613cdf..db6123a5c8 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/09-modifiers/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/09-modifiers/index.md @@ -2,4 +2,4 @@ # 2.9. Modifiers ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/09-modifiers/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/09-modifiers/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/10-events/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/10-events/index.md index f8c52171c9..92ad076783 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/10-events/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/10-events/index.md @@ -2,4 +2,4 @@ # 2.10 Events ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/10-events/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/10-events/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/11-user-defined-value-types/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/11-user-defined-value-types/index.md index 94a3005cc3..cff0a46ae4 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/11-user-defined-value-types/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/11-user-defined-value-types/index.md @@ -2,4 +2,4 @@ # 2.11. User Defined Value Types ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/11-user-defined-value-types/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/11-user-defined-value-types/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/12-errors/index.md b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/12-errors/index.md index 08c26fecd6..b243325afd 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/02-definitions/12-errors/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/02-definitions/12-errors/index.md @@ -2,4 +2,4 @@ # 2.12. Errors ---8<-- "crates/solidity/inputs/schema/grammar/02-definitions/12-errors/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/02-definitions/12-errors/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/03-types/01-advanced-types/index.md b/crates/solidity/outputs/spec/generated/public/reference/03-types/01-advanced-types/index.md index c2b50b5589..59139a3e5d 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/03-types/01-advanced-types/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/03-types/01-advanced-types/index.md @@ -2,4 +2,4 @@ # 3.1. Advanced Types ---8<-- "crates/solidity/inputs/schema/grammar/03-types/01-advanced-types/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/03-types/01-advanced-types/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/03-types/02-elementary-types/index.md b/crates/solidity/outputs/spec/generated/public/reference/03-types/02-elementary-types/index.md index d13f6a40ad..9193d6f8f4 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/03-types/02-elementary-types/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/03-types/02-elementary-types/index.md @@ -2,4 +2,4 @@ # 3.2. Elementary Types ---8<-- "crates/solidity/inputs/schema/grammar/03-types/02-elementary-types/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/03-types/02-elementary-types/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/04-statements/01-blocks/index.md b/crates/solidity/outputs/spec/generated/public/reference/04-statements/01-blocks/index.md index 55f0166402..8599450986 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/04-statements/01-blocks/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/04-statements/01-blocks/index.md @@ -2,4 +2,4 @@ # 4.1. Blocks ---8<-- "crates/solidity/inputs/schema/grammar/04-statements/01-blocks/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/04-statements/01-blocks/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/04-statements/02-declaration-statements/index.md b/crates/solidity/outputs/spec/generated/public/reference/04-statements/02-declaration-statements/index.md index 25213ad586..398b86f510 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/04-statements/02-declaration-statements/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/04-statements/02-declaration-statements/index.md @@ -2,4 +2,4 @@ # 4.2. Declaration Statements ---8<-- "crates/solidity/inputs/schema/grammar/04-statements/02-declaration-statements/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/04-statements/02-declaration-statements/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/04-statements/03-control-statements/index.md b/crates/solidity/outputs/spec/generated/public/reference/04-statements/03-control-statements/index.md index a26418d09a..0b3736291d 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/04-statements/03-control-statements/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/04-statements/03-control-statements/index.md @@ -2,4 +2,4 @@ # 4.3. Control Statements ---8<-- "crates/solidity/inputs/schema/grammar/04-statements/03-control-statements/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/04-statements/03-control-statements/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/04-statements/04-error-handling/index.md b/crates/solidity/outputs/spec/generated/public/reference/04-statements/04-error-handling/index.md index 3cf765fc8c..2318c33942 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/04-statements/04-error-handling/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/04-statements/04-error-handling/index.md @@ -2,4 +2,4 @@ # 4.4. Error Handling ---8<-- "crates/solidity/inputs/schema/grammar/04-statements/04-error-handling/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/04-statements/04-error-handling/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/01-base-expressions/index.md b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/01-base-expressions/index.md index 684a125ab8..e6c98871c6 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/01-base-expressions/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/01-base-expressions/index.md @@ -2,4 +2,4 @@ # 5.1. Base Expressions ---8<-- "crates/solidity/inputs/schema/grammar/05-expressions/01-base-expressions/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/05-expressions/01-base-expressions/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/02-primary-expressions/index.md b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/02-primary-expressions/index.md index 89d07e5a83..e6762e6505 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/02-primary-expressions/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/02-primary-expressions/index.md @@ -2,4 +2,4 @@ # 5.2. Primary Expressions ---8<-- "crates/solidity/inputs/schema/grammar/05-expressions/02-primary-expressions/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/05-expressions/02-primary-expressions/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/03-numbers/index.md b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/03-numbers/index.md index 6f5e031f83..b2ea5c43a2 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/03-numbers/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/03-numbers/index.md @@ -2,4 +2,4 @@ # 5.3. Numbers ---8<-- "crates/solidity/inputs/schema/grammar/05-expressions/03-numbers/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/05-expressions/03-numbers/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/04-strings/index.md b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/04-strings/index.md index a8b7e52341..6e0b9700ea 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/04-strings/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/04-strings/index.md @@ -2,4 +2,4 @@ # 5.4. Strings ---8<-- "crates/solidity/inputs/schema/grammar/05-expressions/04-strings/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/05-expressions/04-strings/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/05-identifiers/index.md b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/05-identifiers/index.md index 0f9ce85d08..e20f04a106 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/05-expressions/05-identifiers/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/05-expressions/05-identifiers/index.md @@ -2,4 +2,4 @@ # 5.5. Identifiers ---8<-- "crates/solidity/inputs/schema/grammar/05-expressions/05-identifiers/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/05-expressions/05-identifiers/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/06-yul/01-assembly-block/index.md b/crates/solidity/outputs/spec/generated/public/reference/06-yul/01-assembly-block/index.md index 8bc0d5d8b1..9030f2c371 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/06-yul/01-assembly-block/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/06-yul/01-assembly-block/index.md @@ -2,4 +2,4 @@ # 6.1. Assembly Block ---8<-- "crates/solidity/inputs/schema/grammar/06-yul/01-assembly-block/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/06-yul/01-assembly-block/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/06-yul/02-yul-statements/index.md b/crates/solidity/outputs/spec/generated/public/reference/06-yul/02-yul-statements/index.md index 19580601a1..390b42c8e0 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/06-yul/02-yul-statements/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/06-yul/02-yul-statements/index.md @@ -2,4 +2,4 @@ # 6.2. Yul Statements ---8<-- "crates/solidity/inputs/schema/grammar/06-yul/02-yul-statements/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/06-yul/02-yul-statements/notes.md" diff --git a/crates/solidity/outputs/spec/generated/public/reference/06-yul/03-yul-expressions/index.md b/crates/solidity/outputs/spec/generated/public/reference/06-yul/03-yul-expressions/index.md index 3b8bc7d0d3..0620be16da 100644 --- a/crates/solidity/outputs/spec/generated/public/reference/06-yul/03-yul-expressions/index.md +++ b/crates/solidity/outputs/spec/generated/public/reference/06-yul/03-yul-expressions/index.md @@ -2,4 +2,4 @@ # 6.3. Yul Expressions ---8<-- "crates/solidity/inputs/schema/grammar/06-yul/03-yul-expressions/notes.md" +--8<-- "crates/solidity/inputs/schema/definition/06-yul/03-yul-expressions/notes.md" diff --git a/crates/solidity/testing/smoke/src/main.rs b/crates/solidity/testing/smoke/src/main.rs index 94cdc9b3b1..0d6553e82e 100644 --- a/crates/solidity/testing/smoke/src/main.rs +++ b/crates/solidity/testing/smoke/src/main.rs @@ -4,11 +4,11 @@ mod reporting; use std::{collections::HashSet, path::PathBuf}; use anyhow::Result; -use codegen_schema::types::grammar::Grammar; +use codegen_schema::types::schema::Schema; use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use semver::Version; use slang_solidity::{syntax::parser::ProductionKind, Language}; -use solidity_schema::SolidityGrammarExtensions; +use solidity_schema::SoliditySchemaExtensions; use solidity_testing_utils::version_pragmas::extract_version_pragmas; use crate::{ @@ -19,10 +19,10 @@ use crate::{ fn main() { // Fail the parent process if a child thread panics: std::panic::catch_unwind(|| -> Result<()> { - let grammar = &Grammar::load_solidity()?; + let schema = &Schema::load_solidity()?; for dataset in get_all_datasets()? { - process_dataset(&dataset, &grammar.versions)?; + process_dataset(&dataset, &schema.versions)?; } return Ok(()); diff --git a/documentation/overrides/partials/actions.html b/documentation/overrides/partials/actions.html index 91652436f5..57bba6a82b 100644 --- a/documentation/overrides/partials/actions.html +++ b/documentation/overrides/partials/actions.html @@ -20,13 +20,19 @@ IN THE SOFTWARE. --> + + {% set edit_url = page.edit_url %} {% if edit_url is string %} {% if "/documentation/public/solidity-specification/" in edit_url %} - - {% set edit_url = config.repo_url + "/edit/main/crates/solidity/inputs/schema/grammar" %} + + {% set edit_url = config.repo_url + "/edit/main/crates/solidity/inputs/schema/definition" %} {% endif %} diff --git a/documentation/public/internals/development/slang architecture.excalidraw b/documentation/public/internals/development/slang-architecture.excalidraw similarity index 99% rename from documentation/public/internals/development/slang architecture.excalidraw rename to documentation/public/internals/development/slang-architecture.excalidraw index 0b7c8bbc9f..617eaffcc2 100644 --- a/documentation/public/internals/development/slang architecture.excalidraw +++ b/documentation/public/internals/development/slang-architecture.excalidraw @@ -7262,11 +7262,11 @@ "locked": false, "fontSize": 20, "fontFamily": 2, - "text": "Annotated Grammar", + "text": "Annotated Schema", "textAlign": "center", "verticalAlign": "top", "containerId": null, - "originalText": "Annotated Grammar", + "originalText": "Annotated Schema", "lineHeight": 1.15, "baseline": 18 }, diff --git a/scripts/solidity/check-grammar.sh b/scripts/solidity/validate-schema.sh similarity index 80% rename from scripts/solidity/check-grammar.sh rename to scripts/solidity/validate-schema.sh index eefb2bd231..6b51fa0ba2 100755 --- a/scripts/solidity/check-grammar.sh +++ b/scripts/solidity/validate-schema.sh @@ -4,7 +4,7 @@ set -euo pipefail source "$(dirname "${BASH_SOURCE[0]}")/../_common.sh" ( - printf "\n\n🧪 Checking Solidity Grammar 🧪\n\n\n" + printf "\n\n🧪 Checking Solidity Schema 🧪\n\n\n" cargo check --offline --lib \ --manifest-path "$REPO_ROOT/crates/solidity/inputs/schema/Cargo.toml"