diff --git a/.vscode/settings.json b/.vscode/settings.json index bf0a74e804..5a97af99cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,8 @@ "editor.rulers": [120], "files.associations": { "**/documentation/overrides/**/*.html": "jinja-html", - "*.ts.jinja2": "jinja-js" // until this is merged: https://github.com/samuelcolvin/jinjahtml-vscode/pull/148 + "*.ts.jinja2": "jinja-js", // until this is merged: https://github.com/samuelcolvin/jinjahtml-vscode/pull/148 + "*.wit.jinja2": "jinja" // until this is merged: https://github.com/samuelcolvin/jinjahtml-vscode/pull/148 }, "editor.unicodeHighlight.allowedCharacters": { "꞉": true // used in CST snapshot tests diff --git a/Cargo.lock b/Cargo.lock index 1aa8cb7940..a13018e6aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,7 +330,6 @@ dependencies = [ "codegen_language_definition", "derive-new", "indexmap", - "strum_macros", ] [[package]] @@ -346,6 +345,7 @@ dependencies = [ "quote", "semver", "serde", + "strum", "strum_macros", "syn", "thiserror", @@ -387,15 +387,18 @@ dependencies = [ "anyhow", "ariadne", "codegen_runtime_generator", + "infra_utils", "metaslang_cst", "napi", "napi-derive", + "paste", "semver", "serde", "serde_json", "strum", "strum_macros", "thiserror", + "wit-bindgen", ] [[package]] @@ -413,7 +416,7 @@ dependencies = [ "quote", "semver", "serde", - "strum_macros", + "strum", ] [[package]] @@ -980,6 +983,12 @@ dependencies = [ "cc", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "idna" version = "0.4.0" @@ -1124,6 +1133,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" version = "0.2.153" @@ -1433,6 +1448,12 @@ dependencies = [ "regex", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -1935,6 +1956,7 @@ dependencies = [ "codegen_runtime_generator", "infra_utils", "metaslang_cst", + "paste", "semver", "serde", "serde_json", @@ -1942,6 +1964,7 @@ dependencies = [ "strum", "strum_macros", "thiserror", + "wit-bindgen", ] [[package]] @@ -1968,6 +1991,7 @@ dependencies = [ "codegen_runtime_generator", "infra_utils", "metaslang_cst", + "paste", "semver", "serde", "strum", @@ -2109,6 +2133,15 @@ dependencies = [ "url", ] +[[package]] +name = "spdx" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47317bbaf63785b53861e1ae2d11b80d6b624211d42cb20efcd210ee6f8a14bc" +dependencies = [ + "smallvec", +] + [[package]] name = "string-interner" version = "0.17.0" @@ -2535,6 +2568,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "url" version = "2.4.0" @@ -2688,6 +2727,44 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +[[package]] +name = "wasm-encoder" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d32029ce424f6d3c2b39b4419fb45a0e2d84fb0751e0c0a32b7ce8bd5d97f46" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" +dependencies = [ + "ahash", + "bitflags 2.5.0", + "hashbrown", + "indexmap", + "semver", +] + [[package]] name = "web-sys" version = "0.3.64" @@ -2889,6 +2966,101 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-bindgen" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a84376ff4f74ed07674a1157c0bd19e6627ab01fc90952a27ccefb52a24530f0" +dependencies = [ + "wit-bindgen-rt", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36d4706efb67fadfbbde77955b299b111dd096e6776d8c6561d92f6147941880" +dependencies = [ + "anyhow", + "heck 0.5.0", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" +dependencies = [ + "bitflags 2.5.0", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514295193d1a2f42e6a948cd7d9fd81e2b8fadc319667dcf19fd7aceaf2113a2" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0409a3356ca02599aff78f717968fd7f12df4bf879f325e2a97b45c84c90fff" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bb5b039f9cb03425e1d5a6e54b441ca4ca1b1d4fa6a0924db67a55168f99" +dependencies = [ + "anyhow", + "bitflags 2.5.0", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 852f4ecdbb..6f0d255518 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,6 +107,7 @@ napi-derive = { version = "2.16.5" } nom = { version = "7.1.3" } num-format = { version = "0.4.4" } once_cell = { version = "1.19.0" } +paste = { version = "1.0.15" } proc-macro2 = { version = "1.0.84" } quote = { version = "1.0.36" } rayon = { version = "1.10.0" } @@ -134,6 +135,8 @@ thiserror = { version = "1.0.61" } trybuild = { version = "1.0.96" } toml = { version = "0.8.13" } url = { version = "2.3.1" } +wit-bindgen = { version = "0.26.0" } +wit-bindgen-cli = { version = "0.26.0" } [workspace.lints.rust] unused_crate_dependencies = "warn" diff --git a/crates/codegen/ebnf/Cargo.toml b/crates/codegen/ebnf/Cargo.toml index 43cebdead0..3c91582b73 100644 --- a/crates/codegen/ebnf/Cargo.toml +++ b/crates/codegen/ebnf/Cargo.toml @@ -11,7 +11,6 @@ codegen_language_definition = { workspace = true } derive-new = { workspace = true } indexmap = { workspace = true } Inflector = { workspace = true } -strum_macros = { workspace = true } [lints] workspace = true diff --git a/crates/codegen/ebnf/src/builder.rs b/crates/codegen/ebnf/src/builder.rs index a77dc38885..9b90053be9 100644 --- a/crates/codegen/ebnf/src/builder.rs +++ b/crates/codegen/ebnf/src/builder.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use codegen_language_definition::model::{ - EnumItem, EnumVariant, Field, FragmentItem, Identifier, Item, KeywordDefinition, KeywordItem, - KeywordValue, Language, OperatorModel, PrecedenceExpression, PrecedenceItem, + BuiltInLabel, EnumItem, EnumVariant, Field, FragmentItem, Identifier, Item, KeywordDefinition, + KeywordItem, KeywordValue, Language, OperatorModel, PrecedenceExpression, PrecedenceItem, PrecedenceOperator, PrimaryExpression, RepeatedItem, Scanner, SeparatedItem, StructItem, TokenDefinition, TokenItem, TriviaItem, VersionSpecifier, }; @@ -11,21 +11,6 @@ use inflector::Inflector; use crate::model::{Definition, DefinitionKind, Entry, Expression, Value}; -#[allow(dead_code)] -#[derive(strum_macros::AsRefStr)] -#[strum(serialize_all = "snake_case")] -enum BuiltInLabel { - // _SLANG_INTERNAL_RESERVED_NODE_LABELS_ (keep in sync) - Item, - Variant, - Separator, - Operand, - LeftOperand, - RightOperand, - LeadingTrivia, - TrailingTrivia, -} - pub struct Builder { section_index: usize, topic_index: usize, diff --git a/crates/codegen/language/definition/Cargo.toml b/crates/codegen/language/definition/Cargo.toml index b1db94fb47..469be1631b 100644 --- a/crates/codegen/language/definition/Cargo.toml +++ b/crates/codegen/language/definition/Cargo.toml @@ -15,6 +15,7 @@ proc-macro2 = { workspace = true } quote = { workspace = true } semver = { workspace = true } serde = { workspace = true } +strum = { workspace = true } strum_macros = { workspace = true } syn = { workspace = true } thiserror = { workspace = true } diff --git a/crates/codegen/language/definition/src/model/manifest.rs b/crates/codegen/language/definition/src/model/manifest.rs index a26e9c2b7f..92158ab153 100644 --- a/crates/codegen/language/definition/src/model/manifest.rs +++ b/crates/codegen/language/definition/src/model/manifest.rs @@ -36,27 +36,15 @@ impl Language { } /// Collects all versions that change the language grammar in a breaking way. + /// + /// Includes the first supported version. pub fn collect_breaking_versions(&self) -> BTreeSet { let first = self.versions.first().unwrap().clone(); let mut res = BTreeSet::from_iter([first]); let mut add_spec = |spec: &Option| { - let Some(spec) = spec else { - return; - }; - - match spec.clone() { - VersionSpecifier::Never => (), - VersionSpecifier::From { from } => { - res.insert(from); - } - VersionSpecifier::Till { till } => { - res.insert(till); - } - VersionSpecifier::Range { from, till } => { - res.insert(from); - res.insert(till); - } + if let Some(spec) = spec { + res.extend(spec.versions().cloned()); } }; @@ -139,3 +127,16 @@ pub struct Topic { pub items: Vec, } + +#[derive(strum_macros::AsRefStr, strum_macros::EnumIter, strum_macros::VariantNames)] +#[strum(serialize_all = "snake_case")] +pub enum BuiltInLabel { + Item, + Variant, + Separator, + Operand, + LeftOperand, + RightOperand, + LeadingTrivia, + TrailingTrivia, +} diff --git a/crates/codegen/runtime/cargo/Cargo.toml b/crates/codegen/runtime/cargo/Cargo.toml index 9b3caf8551..c75c311edb 100644 --- a/crates/codegen/runtime/cargo/Cargo.toml +++ b/crates/codegen/runtime/cargo/Cargo.toml @@ -10,23 +10,27 @@ description = "Cargo runtime copied over by codegen" [build-dependencies] anyhow = { workspace = true } codegen_runtime_generator = { workspace = true } +infra_utils = { workspace = true } [dependencies] ariadne = { workspace = true, optional = true } metaslang_cst = { workspace = true } napi = { workspace = true, optional = true } napi-derive = { workspace = true, optional = true } +paste = { workspace = true } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true, optional = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } +wit-bindgen = { workspace = true, optional = true } # Since the source code is copied over as-is, we need to retain exact feature set with target crate, # i.e `slang_solidity_node_addon`. [features] -default = ["slang_napi_interfaces"] +default = ["slang_napi_interfaces", "wit"] +wit = ["dep:wit-bindgen"] slang_napi_interfaces = ["dep:napi", "dep:napi-derive", "dep:serde_json"] # Only used by the `slang_solidity` CLI __private_ariadne = ["dep:ariadne"] diff --git a/crates/codegen/runtime/cargo/build.rs b/crates/codegen/runtime/cargo/build.rs index 6ab086731c..2a5ba3b2ef 100644 --- a/crates/codegen/runtime/cargo/build.rs +++ b/crates/codegen/runtime/cargo/build.rs @@ -1,6 +1,11 @@ use anyhow::Result; use codegen_runtime_generator::OutputLanguage; +use infra_utils::cargo::CargoWorkspace; fn main() -> Result<()> { - OutputLanguage::Cargo.generate_stubs() + OutputLanguage::Cargo.generate_stubs()?; + let output_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_cargo")?.join("src/runtime"); + OutputLanguage::Cargo.wit_bindgen(&output_dir)?; + Ok(()) } diff --git a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs index c6cdd991c0..6d413272c1 100644 --- a/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs +++ b/crates/codegen/runtime/cargo/src/runtime/generated/kinds.rs @@ -3,6 +3,8 @@ #[cfg(feature = "slang_napi_interfaces")] use napi_derive::napi; +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -26,6 +28,8 @@ pub enum NonterminalKind { impl metaslang_cst::NonterminalKind for NonterminalKind {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -61,6 +65,8 @@ pub enum EdgeLabel { impl metaslang_cst::EdgeLabel for EdgeLabel {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -93,6 +99,8 @@ impl metaslang_cst::TerminalKind for TerminalKind { } /// The lexical context of the scanner. +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive(strum_macros::FromRepr, Clone, Copy)] pub(crate) enum LexicalContext { Stub1, diff --git a/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 index 850d2499ce..5213a927ad 100644 --- a/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/kinds.rs.jinja2 @@ -1,6 +1,8 @@ #[cfg(feature = "slang_napi_interfaces")] use napi_derive::napi; +// This needs to stay in sync with the wit-bindgen output +{% if model.kinds.nonterminal_kinds|length <= 256 %} #[repr(u8)] {% else %} #[repr(u16)] {% endif %} #[derive( Debug, Eq, @@ -31,6 +33,8 @@ pub enum NonterminalKind { impl metaslang_cst::NonterminalKind for NonterminalKind {} +// This needs to stay in sync with the wit-bindgen output +{% if model.kinds.labels|length <= 256 %} #[repr(u8)] {% else %} #[repr(u16)] {% endif %} #[derive( Debug, Eq, @@ -49,15 +53,9 @@ impl metaslang_cst::NonterminalKind for NonterminalKind {} #[cfg_attr(not(feature = "slang_napi_interfaces"), derive(Clone, Copy))] pub enum EdgeLabel { // Built-in: - {# _SLANG_INTERNAL_RESERVED_NODE_LABELS_ (keep in sync) #} - Item, - Variant, - Separator, - Operand, - LeftOperand, - RightOperand, - LeadingTrivia, - TrailingTrivia, + {% for label in model.kinds.built_in_labels -%} + {{ label | pascal_case }}, + {%- endfor %} // Generated: {% if rendering_in_stubs -%} @@ -73,6 +71,8 @@ pub enum EdgeLabel { impl metaslang_cst::EdgeLabel for EdgeLabel {} +// This needs to stay in sync with the wit-bindgen output +{% if model.kinds.terminal_kinds|length <= 256 %} #[repr(u8)] {% else %} #[repr(u16)] {% endif %} #[derive( Debug, Eq, @@ -121,6 +121,8 @@ impl metaslang_cst::TerminalKind for TerminalKind { } /// The lexical context of the scanner. +// This needs to stay in sync with the wit-bindgen output +{% if model.kinds.lexical_contexts|length <= 256 %} #[repr(u8)] {% else %} #[repr(u16)] {% endif %} #[derive(strum_macros::FromRepr, Clone, Copy)] pub(crate) enum LexicalContext { {%- if rendering_in_stubs -%} diff --git a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 index 488add51f2..34d5c64cbf 100644 --- a/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 +++ b/crates/codegen/runtime/cargo/src/runtime/language.rs.jinja2 @@ -30,7 +30,10 @@ use crate::parser_support::{ #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { {%- if not rendering_in_stubs -%} - {%- for version in model.parser.referenced_versions -%} + {%- for version in model.breaking_versions -%} + {% if loop.first %} {# The first supported version may not be referenced by the items #} + #[allow(dead_code)] + {% endif %} pub(crate) version_is_at_least_{{ version | replace(from=".", to="_") }}: bool, {%- endfor -%} {%- endif -%} @@ -68,7 +71,7 @@ impl Language { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { {%- if not rendering_in_stubs -%} - {%- for version in model.parser.referenced_versions %} + {%- for version in model.breaking_versions %} version_is_at_least_{{ version | replace(from=".", to="_") }}: Version::new({{ version | split(pat=".") | join(sep=", ") }}) <= version, {%- endfor -%} {%- endif -%} diff --git a/crates/codegen/runtime/cargo/src/runtime/mod.rs b/crates/codegen/runtime/cargo/src/runtime/mod.rs index 10c77e6ca3..ea4e0eb3df 100644 --- a/crates/codegen/runtime/cargo/src/runtime/mod.rs +++ b/crates/codegen/runtime/cargo/src/runtime/mod.rs @@ -10,6 +10,9 @@ pub mod language; pub mod parse_error; pub mod parse_output; +#[cfg(feature = "wit")] +pub mod wit; + #[cfg(feature = "slang_napi_interfaces")] pub mod napi_interface; @@ -63,6 +66,7 @@ pub mod query { pub type Query = query::Query; pub type QueryMatch = query::QueryMatch; pub type QueryMatchIterator = query::QueryMatchIterator; + pub use query::QueryError; } pub mod text_index { diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/cst.rs b/crates/codegen/runtime/cargo/src/runtime/wit/cst.rs new file mode 100644 index 0000000000..916cdca831 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/cst.rs @@ -0,0 +1,65 @@ +use super::{define_rc_wrapper, ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// resource nonterminal-node +// +//================================================ + +define_rc_wrapper! { NonterminalNode { + fn kind(&self) -> ffi::NonterminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text_len(&self) -> ffi::TextIndex { + self._borrow_ffi().text_len._into_ffi() + } + + fn children(&self) -> Vec { + todo!() + } + + fn create_cursor(&self, text_offset: ffi::TextIndex) -> ffi::Cursor { + std::rc::Rc::clone(self._borrow_ffi()).cursor_with_offset(text_offset._from_ffi())._into_ffi() + } + + fn unparse(&self) -> String { + std::rc::Rc::clone(self._borrow_ffi()).unparse() + } +} } + +//================================================ +// +// resource terminal-node +// +//================================================ + +define_rc_wrapper! { TerminalNode { + fn kind(&self) -> ffi::TerminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text(&self) -> String { + self._borrow_ffi().text.clone() + } + + fn text_len(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + } +} } + +//================================================ +// +// variant node +// +//================================================ + +impl IntoFFI for rust::Node { + #[inline] + fn _into_ffi(self) -> ffi::Node { + match self { + Self::Nonterminal(node) => ffi::Node::Nonterminal(node._into_ffi()), + Self::Terminal(node) => ffi::Node::Terminal(node._into_ffi()), + } + } +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/cursor.rs b/crates/codegen/runtime/cargo/src/runtime/wit/cursor.rs new file mode 100644 index 0000000000..506e110167 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/cursor.rs @@ -0,0 +1,123 @@ +use super::{define_refcell_wrapper, ffi, rust, FromFFI, IntoFFI}; +//================================================ +// +// resource cursor +// +//================================================ + +define_refcell_wrapper! { Cursor { + fn reset(&self) { + self._borrow_mut_ffi().reset(); + } + + fn complete(&self) { + self._borrow_mut_ffi().complete(); + } + + fn is_completed(&self) -> bool { + self._borrow_ffi().is_completed() + } + + fn clone(&self) -> ffi::Cursor { + self._borrow_ffi().clone()._into_ffi() + } + + fn spawn(&self) -> ffi::Cursor { + self._borrow_ffi().spawn()._into_ffi() + } + + fn node(&self) -> ffi::Node { + self._borrow_ffi().node()._into_ffi() + } + + fn label(&self) -> Option { + self._borrow_ffi().label().map(IntoFFI::_into_ffi) + } + + fn text_offset(&self) -> ffi::TextIndex { + self._borrow_ffi().text_offset()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + #[allow(clippy::cast_possible_truncation)] + fn depth(&self) -> u32 { + self._borrow_ffi().depth() as u32 + } + + fn ancestors(&self) -> Vec { + self._borrow_ffi().ancestors().map(|x|x._into_ffi()).collect() + } + + fn go_to_next(&self) -> bool { + self._borrow_mut_ffi().go_to_next() + } + + fn go_to_next_non_descendent(&self) -> bool { + self._borrow_mut_ffi().go_to_next_non_descendent() + } + + fn go_to_previous(&self) -> bool { + self._borrow_mut_ffi().go_to_previous() + } + + fn go_to_parent(&self) -> bool { + self._borrow_mut_ffi().go_to_parent() + } + + fn go_to_first_child(&self) -> bool { + self._borrow_mut_ffi().go_to_first_child() + } + + fn go_to_last_child(&self) -> bool { + self._borrow_mut_ffi().go_to_last_child() + } + + fn go_to_nth_child(&self, child_number: u32) -> bool { + self._borrow_mut_ffi().go_to_nth_child(child_number as usize) + } + + fn go_to_next_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_next_sibling() + } + + fn go_to_previous_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_previous_sibling() + } + + fn go_to_next_terminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_terminal() + } + + fn go_to_next_terminal_with_kind(&self, kind: ffi::TerminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_terminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_terminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_terminal_with_kinds(&kinds) + } + + fn go_to_next_nonterminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal() + } + + fn go_to_next_nonterminal_with_kind(&self, kind: ffi::NonterminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_nonterminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_nonterminal_with_kinds(&kinds) + } + + fn query(&self, queries: Vec>) -> ffi::QueryMatchIterator { + let queries:Vec = queries.into_iter().map(|q|{ + q._borrow_ffi().clone() + }).collect(); + + self._borrow_ffi().clone().query(queries)._into_ffi() + } +} } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/diagnostic.rs b/crates/codegen/runtime/cargo/src/runtime/wit/diagnostic.rs new file mode 100644 index 0000000000..b4057179c0 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/diagnostic.rs @@ -0,0 +1,9 @@ +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum severity +// +//================================================ + +enum_to_enum!(Severity); diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.rs b/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.rs new file mode 100644 index 0000000000..f21676e24f --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.rs @@ -0,0 +1,3641 @@ +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! +// Options used: +// * default-bindings-module: "$crate::wit::slang" +// * pub-export-macro +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod nomic { + #[allow(dead_code)] + pub mod slang { + #[allow(dead_code, clippy::all)] + pub mod parser { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum NonterminalKind { + Stub1, + Stub2, + Stub3, + } + impl ::core::fmt::Debug for NonterminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + NonterminalKind::Stub1 => { + f.debug_tuple("NonterminalKind::Stub1").finish() + } + NonterminalKind::Stub2 => { + f.debug_tuple("NonterminalKind::Stub2").finish() + } + NonterminalKind::Stub3 => { + f.debug_tuple("NonterminalKind::Stub3").finish() + } + } + } + } + + impl NonterminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> NonterminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => NonterminalKind::Stub1, + 1 => NonterminalKind::Stub2, + 2 => NonterminalKind::Stub3, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum EdgeLabel { + /// Built-in: + Item, + Variant, + Separator, + Operand, + LeftOperand, + RightOperand, + LeadingTrivia, + TrailingTrivia, + /// Generated: + Stub1, + Stub2, + Stub3, + } + impl ::core::fmt::Debug for EdgeLabel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + EdgeLabel::Item => f.debug_tuple("EdgeLabel::Item").finish(), + EdgeLabel::Variant => f.debug_tuple("EdgeLabel::Variant").finish(), + EdgeLabel::Separator => f.debug_tuple("EdgeLabel::Separator").finish(), + EdgeLabel::Operand => f.debug_tuple("EdgeLabel::Operand").finish(), + EdgeLabel::LeftOperand => { + f.debug_tuple("EdgeLabel::LeftOperand").finish() + } + EdgeLabel::RightOperand => { + f.debug_tuple("EdgeLabel::RightOperand").finish() + } + EdgeLabel::LeadingTrivia => { + f.debug_tuple("EdgeLabel::LeadingTrivia").finish() + } + EdgeLabel::TrailingTrivia => { + f.debug_tuple("EdgeLabel::TrailingTrivia").finish() + } + EdgeLabel::Stub1 => f.debug_tuple("EdgeLabel::Stub1").finish(), + EdgeLabel::Stub2 => f.debug_tuple("EdgeLabel::Stub2").finish(), + EdgeLabel::Stub3 => f.debug_tuple("EdgeLabel::Stub3").finish(), + } + } + } + + impl EdgeLabel { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> EdgeLabel { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => EdgeLabel::Item, + 1 => EdgeLabel::Variant, + 2 => EdgeLabel::Separator, + 3 => EdgeLabel::Operand, + 4 => EdgeLabel::LeftOperand, + 5 => EdgeLabel::RightOperand, + 6 => EdgeLabel::LeadingTrivia, + 7 => EdgeLabel::TrailingTrivia, + 8 => EdgeLabel::Stub1, + 9 => EdgeLabel::Stub2, + 10 => EdgeLabel::Stub3, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum TerminalKind { + /// Built-in: + Skipped, + /// Generated: + Stub1, + Stub2, + Stub3, + } + impl ::core::fmt::Debug for TerminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + TerminalKind::Skipped => { + f.debug_tuple("TerminalKind::Skipped").finish() + } + TerminalKind::Stub1 => f.debug_tuple("TerminalKind::Stub1").finish(), + TerminalKind::Stub2 => f.debug_tuple("TerminalKind::Stub2").finish(), + TerminalKind::Stub3 => f.debug_tuple("TerminalKind::Stub3").finish(), + } + } + } + + impl TerminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> TerminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => TerminalKind::Skipped, + 1 => TerminalKind::Stub1, + 2 => TerminalKind::Stub2, + 3 => TerminalKind::Stub3, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Language { + handle: _rt::Resource, + } + + type _LanguageRep = Option; + + impl Language { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Language`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _LanguageRep = Some(val); + let ptr: *mut _LanguageRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestLanguage` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _LanguageRep); + } + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Language`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct LanguageBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Language>, + } + + impl<'a> LanguageBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Language { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]language"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseError { + handle: _rt::Resource, + } + + type _ParseErrorRep = Option; + + impl ParseError { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseError`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseErrorRep = Some(val); + let ptr: *mut _ParseErrorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseError` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseErrorRep); + } + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseError`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseErrorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseError>, + } + + impl<'a> ParseErrorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseError { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutput { + handle: _rt::Resource, + } + + type _ParseOutputRep = Option; + + impl ParseOutput { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseOutput`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseOutputRep = Some(val); + let ptr: *mut _ParseOutputRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseOutput` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseOutputRep); + } + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseOutput`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutputBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseOutput>, + } + + impl<'a> ParseOutputBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseOutput { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-output"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNode { + handle: _rt::Resource, + } + + type _NonterminalNodeRep = Option; + + impl NonterminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `NonterminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _NonterminalNodeRep = Some(val); + let ptr: *mut _NonterminalNodeRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestNonterminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _NonterminalNodeRep); + } + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`NonterminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a NonterminalNode>, + } + + impl<'a> NonterminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for NonterminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]nonterminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNode { + handle: _rt::Resource, + } + + type _TerminalNodeRep = Option; + + impl TerminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `TerminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _TerminalNodeRep = Some(val); + let ptr: *mut _TerminalNodeRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestTerminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _TerminalNodeRep); + } + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`TerminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a TerminalNode>, + } + + impl<'a> TerminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for TerminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]terminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub enum Node { + Nonterminal(NonterminalNode), + Terminal(TerminalNode), + } + impl ::core::fmt::Debug for Node { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Node::Nonterminal(e) => { + f.debug_tuple("Node::Nonterminal").field(e).finish() + } + Node::Terminal(e) => f.debug_tuple("Node::Terminal").field(e).finish(), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Cursor { + handle: _rt::Resource, + } + + type _CursorRep = Option; + + impl Cursor { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Cursor`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CursorRep = Some(val); + let ptr: *mut _CursorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCursor` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CursorRep); + } + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Cursor`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CursorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Cursor>, + } + + impl<'a> CursorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Cursor { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]cursor"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Query { + handle: _rt::Resource, + } + + type _QueryRep = Option; + + impl Query { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Query`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryRep = Some(val); + let ptr: *mut _QueryRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQuery` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryRep); + } + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Query`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Query>, + } + + impl<'a> QueryBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Query { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Clone)] + pub struct QueryError { + pub message: _rt::String, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryError") + .field("message", &self.message) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + impl ::core::fmt::Display for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for QueryError {} + pub struct QueryMatch { + pub query_number: u32, + pub captures: _rt::Vec<(_rt::String, _rt::Vec)>, + } + impl ::core::fmt::Debug for QueryMatch { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryMatch") + .field("query-number", &self.query_number) + .field("captures", &self.captures) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIterator { + handle: _rt::Resource, + } + + type _QueryMatchIteratorRep = Option; + + impl QueryMatchIterator { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `QueryMatchIterator`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryMatchIteratorRep = Some(val); + let ptr: *mut _QueryMatchIteratorRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQueryMatchIterator` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryMatchIteratorRep); + } + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`QueryMatchIterator`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIteratorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a QueryMatchIterator>, + } + + impl<'a> QueryMatchIteratorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for QueryMatchIterator { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query-match-iterator"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Severity { + Error, + Warning, + Information, + Hint, + } + impl ::core::fmt::Debug for Severity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Severity::Error => f.debug_tuple("Severity::Error").finish(), + Severity::Warning => f.debug_tuple("Severity::Warning").finish(), + Severity::Information => { + f.debug_tuple("Severity::Information").finish() + } + Severity::Hint => f.debug_tuple("Severity::Hint").finish(), + } + } + } + + impl Severity { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Severity { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Severity::Error, + 1 => Severity::Warning, + 2 => Severity::Information, + 3 => Severity::Hint, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextIndex { + pub utf8: u32, + pub utf16: u32, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for TextIndex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextIndex") + .field("utf8", &self.utf8) + .field("utf16", &self.utf16) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextRange { + pub start: TextIndex, + pub end: TextIndex, + } + impl ::core::fmt::Debug for TextRange { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextRange") + .field("start", &self.start) + .field("end", &self.end) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_supported_versions_cabi( + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::supported_versions(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_supported_versions( + arg0: *mut u8, + ) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_new_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::new(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_new(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_version_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::version(LanguageBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_language_version( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_parse_cabi( + arg0: *mut u8, + arg1: i32, + arg2: *mut u8, + arg3: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg3; + let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); + let result1 = T::parse( + LanguageBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + _rt::string_lift(bytes0), + ); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_severity_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::severity(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_message_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::message(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_error_message( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_tree_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::tree(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_errors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::errors(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_output_errors( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_is_valid_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_valid(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_create_tree_cursor_cabi< + T: GuestParseOutput, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::create_tree_cursor(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_text_len_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::text_len(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_children_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::children(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + match e { + Node::Nonterminal(e) => { + *base.add(0).cast::() = (0i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + } + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_children< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_create_cursor_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::create_cursor( + NonterminalNodeBorrow::lift(arg0 as u32 as usize).get(), + TextIndex { + utf8: arg1 as u32, + utf16: arg2 as u32, + line: arg3 as u32, + column: arg4 as u32, + }, + ); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_unparse_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::unparse(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_unparse< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_len_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_len(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_terminal_node_text( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_reset_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::reset(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_complete_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::complete(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_is_completed_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_completed(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_clone_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::clone(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_spawn_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::spawn(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_node_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::node(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_label_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::label(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(1).cast::() = (e.clone() as i32) as u8; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_offset_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_offset(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_depth_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::depth(CursorBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_ancestors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::ancestors(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_cursor_ancestors(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_non_descendent_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_non_descendent( + CursorBorrow::lift(arg0 as u32 as usize).get(), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_previous(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_parent_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_parent(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_first_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_first_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_last_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_last_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_nth_child_cabi( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_nth_child( + CursorBorrow::lift(arg0 as u32 as usize).get(), + arg1 as u32, + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_previous_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_terminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_terminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + TerminalKind::_lift(arg1 as u8), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 1); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + TerminalKind::_lift(l0 as u8) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 1, 1); + let result2 = T::go_to_next_terminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_nonterminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_nonterminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 1); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + NonterminalKind::_lift(l0 as u8) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 1, 1); + let result2 = T::go_to_next_nonterminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_query_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 4); + let e1 = { + let l0 = *base.add(0).cast::(); + + QueryBorrow::lift(l0 as u32 as usize) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 4, 4); + let result2 = T::query(CursorBorrow::lift(arg0 as u32 as usize).get(), result1); + (result2).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_query_parse_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::parse(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let QueryError { + message: message3, + line: line3, + column: column3, + } = e; + let vec4 = (message3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(8).cast::() = len4; + *ptr2.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + *ptr2.add(12).cast::() = _rt::as_i32(line3); + *ptr2.add(16).cast::() = _rt::as_i32(column3); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_query_parse(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_query_match_iterator_next_cabi< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::next(QueryMatchIteratorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let QueryMatch { + query_number: query_number2, + captures: captures2, + } = e; + *ptr1.add(4).cast::() = _rt::as_i32(query_number2); + let vec6 = captures2; + let len6 = vec6.len(); + let layout6 = + _rt::alloc::Layout::from_size_align_unchecked(vec6.len() * 16, 4); + let result6 = if layout6.size() != 0 { + let ptr = _rt::alloc::alloc(layout6).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout6); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6.add(i * 16); + { + let (t3_0, t3_1) = e; + let vec4 = (t3_0.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(4).cast::() = len4; + *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + let vec5 = t3_1; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked( + vec5.len() * 4, + 4, + ); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = result5; + } + } + *ptr1.add(12).cast::() = len6; + *ptr1.add(8).cast::<*mut u8>() = result6; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_query_match_iterator_next< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l6 = *arg0.add(8).cast::<*mut u8>(); + let l7 = *arg0.add(12).cast::(); + let base8 = l6; + let len8 = l7; + for i in 0..len8 { + let base = base8.add(i * 16); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(8).cast::<*mut u8>(); + let l4 = *base.add(12).cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); + } + } + _rt::cabi_dealloc(base8, len8 * 16, 4); + } + } + } + pub trait Guest { + type Language: GuestLanguage; + type ParseError: GuestParseError; + type ParseOutput: GuestParseOutput; + type NonterminalNode: GuestNonterminalNode; + type TerminalNode: GuestTerminalNode; + type Cursor: GuestCursor; + type Query: GuestQuery; + type QueryMatchIterator: GuestQueryMatchIterator; + } + pub trait GuestLanguage: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]language"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]language"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn supported_versions() -> _rt::Vec<_rt::String>; + fn new(version: _rt::String) -> Result; + fn version(&self) -> _rt::String; + fn parse(&self, kind: NonterminalKind, input: _rt::String) -> ParseOutput; + } + pub trait GuestParseError: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-error"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-error"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + /// is-a diagnostic + fn severity(&self) -> Severity; + fn text_range(&self) -> TextRange; + fn message(&self) -> _rt::String; + } + pub trait GuestParseOutput: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-output"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-output"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn tree(&self) -> Node; + fn errors(&self) -> _rt::Vec; + fn is_valid(&self) -> bool; + fn create_tree_cursor(&self) -> Cursor; + } + pub trait GuestNonterminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]nonterminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]nonterminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> NonterminalKind; + fn text_len(&self) -> TextIndex; + fn children(&self) -> _rt::Vec; + fn create_cursor(&self, text_offset: TextIndex) -> Cursor; + fn unparse(&self) -> _rt::String; + } + pub trait GuestTerminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]terminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]terminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> TerminalKind; + fn text_len(&self) -> TextIndex; + fn text(&self) -> _rt::String; + } + pub trait GuestCursor: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]cursor"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]cursor"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn reset(&self); + fn complete(&self); + fn is_completed(&self) -> bool; + fn clone(&self) -> Cursor; + fn spawn(&self) -> Cursor; + fn node(&self) -> Node; + fn label(&self) -> Option; + fn text_offset(&self) -> TextIndex; + fn text_range(&self) -> TextRange; + fn depth(&self) -> u32; + fn ancestors(&self) -> _rt::Vec; + fn go_to_next(&self) -> bool; + fn go_to_next_non_descendent(&self) -> bool; + fn go_to_previous(&self) -> bool; + fn go_to_parent(&self) -> bool; + fn go_to_first_child(&self) -> bool; + fn go_to_last_child(&self) -> bool; + fn go_to_nth_child(&self, child_number: u32) -> bool; + fn go_to_next_sibling(&self) -> bool; + fn go_to_previous_sibling(&self) -> bool; + fn go_to_next_terminal(&self) -> bool; + fn go_to_next_terminal_with_kind(&self, kind: TerminalKind) -> bool; + fn go_to_next_terminal_with_kinds(&self, kinds: _rt::Vec) + -> bool; + fn go_to_next_nonterminal(&self) -> bool; + fn go_to_next_nonterminal_with_kind(&self, kind: NonterminalKind) -> bool; + fn go_to_next_nonterminal_with_kinds( + &self, + kinds: _rt::Vec, + ) -> bool; + fn query(&self, queries: _rt::Vec>) -> QueryMatchIterator; + } + pub trait GuestQuery: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn parse(text: _rt::String) -> Result; + } + pub trait GuestQueryMatchIterator: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query-match-iterator"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query-match-iterator"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn next(&self) -> Option; + } + #[doc(hidden)] + #[macro_export] + macro_rules! __export_nomic_slang_parser_1_0_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn export_static_language_supported_versions() -> *mut u8 { + $($path_to_types)*::_export_static_language_supported_versions_cabi::<<$ty as $($path_to_types)*::Guest>::Language>() + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn _post_return_static_language_supported_versions(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_supported_versions::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn export_static_language_new(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_language_new_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn _post_return_static_language_new(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_new::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn export_method_language_version(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_language_version_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn _post_return_method_language_version(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_language_version::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.parse"] + unsafe extern "C" fn export_method_language_parse(arg0: *mut u8,arg1: i32,arg2: *mut u8,arg3: usize,) -> i32 { + $($path_to_types)*::_export_method_language_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1, arg2, arg3) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.severity"] + unsafe extern "C" fn export_method_parse_error_severity(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_error_severity_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.text-range"] + unsafe extern "C" fn export_method_parse_error_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn export_method_parse_error_message(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_message_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn _post_return_method_parse_error_message(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_error_message::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.tree"] + unsafe extern "C" fn export_method_parse_output_tree(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_tree_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn export_method_parse_output_errors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_errors_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn _post_return_method_parse_output_errors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_output_errors::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.is-valid"] + unsafe extern "C" fn export_method_parse_output_is_valid(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_is_valid_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.create-tree-cursor"] + unsafe extern "C" fn export_method_parse_output_create_tree_cursor(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_create_tree_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.kind"] + unsafe extern "C" fn export_method_nonterminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.text-len"] + unsafe extern "C" fn export_method_nonterminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn export_method_nonterminal_node_children(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_children_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn _post_return_method_nonterminal_node_children(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_children::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.create-cursor"] + unsafe extern "C" fn export_method_nonterminal_node_create_cursor(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_create_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0, arg1, arg2, arg3, arg4) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn export_method_nonterminal_node_unparse(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_unparse_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn _post_return_method_nonterminal_node_unparse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_unparse::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.kind"] + unsafe extern "C" fn export_method_terminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_terminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text-len"] + unsafe extern "C" fn export_method_terminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn export_method_terminal_node_text(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn _post_return_method_terminal_node_text(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_terminal_node_text::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.reset"] + unsafe extern "C" fn export_method_cursor_reset(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_reset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.complete"] + unsafe extern "C" fn export_method_cursor_complete(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_complete_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.is-completed"] + unsafe extern "C" fn export_method_cursor_is_completed(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_is_completed_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.clone"] + unsafe extern "C" fn export_method_cursor_clone(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_clone_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.spawn"] + unsafe extern "C" fn export_method_cursor_spawn(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_spawn_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.node"] + unsafe extern "C" fn export_method_cursor_node(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_node_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.label"] + unsafe extern "C" fn export_method_cursor_label(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_label_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-offset"] + unsafe extern "C" fn export_method_cursor_text_offset(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_offset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-range"] + unsafe extern "C" fn export_method_cursor_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.depth"] + unsafe extern "C" fn export_method_cursor_depth(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_depth_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn export_method_cursor_ancestors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_ancestors_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn _post_return_method_cursor_ancestors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_cursor_ancestors::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next"] + unsafe extern "C" fn export_method_cursor_go_to_next(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-non-descendent"] + unsafe extern "C" fn export_method_cursor_go_to_next_non_descendent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_non_descendent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous"] + unsafe extern "C" fn export_method_cursor_go_to_previous(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-parent"] + unsafe extern "C" fn export_method_cursor_go_to_parent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_parent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-first-child"] + unsafe extern "C" fn export_method_cursor_go_to_first_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_first_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-last-child"] + unsafe extern "C" fn export_method_cursor_go_to_last_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_last_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-nth-child"] + unsafe extern "C" fn export_method_cursor_go_to_nth_child(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_nth_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_next_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_previous_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.query"] + unsafe extern "C" fn export_method_cursor_query(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_query_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn export_static_query_parse(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_query_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Query>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn _post_return_static_query_parse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_query_parse::<<$ty as $($path_to_types)*::Guest>::Query>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn export_method_query_match_iterator_next(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_query_match_iterator_next_cabi::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn _post_return_method_query_match_iterator_next(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_query_match_iterator_next::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]language"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Language::dtor::< + <$ty as $($path_to_types)*::Guest>::Language + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-error"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseError::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseError + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-output"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseOutput::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseOutput + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]nonterminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::NonterminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::NonterminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]terminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::TerminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::TerminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]cursor"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Cursor::dtor::< + <$ty as $($path_to_types)*::Guest>::Cursor + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Query::dtor::< + <$ty as $($path_to_types)*::Guest>::Query + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query-match-iterator"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::QueryMatchIterator::dtor::< + <$ty as $($path_to_types)*::Guest>::QueryMatchIterator + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub use __export_nomic_slang_parser_1_0_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 32]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 32]); + } + } + } +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + pub use alloc_crate::boxed::Box; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen::rt::run_ctors_once(); + } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] +#[macro_export] +macro_rules! __export_slang_impl { + ($ty:ident) => ($crate::wit::slang::export!($ty with_types_in $crate::wit::slang);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::nomic::slang::parser::__export_nomic_slang_parser_1_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::nomic::slang::parser); + const _: () = { + + #[cfg(target_arch = "wasm32")] + #[link_section = "component-type:wit-bindgen:0.26.0:slang:imports and exports"] + #[doc(hidden)] + pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3016] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xcc\x16\x01A\x02\x01\ +A\x02\x01B\x8c\x01\x01m\x03\x05stub1\x05stub2\x05stub3\x04\0\x10nonterminal-kind\ +\x03\0\0\x01m\x0b\x04item\x07variant\x09separator\x07operand\x0cleft-operand\x0d\ +right-operand\x0eleading-trivia\x0ftrailing-trivia\x05stub1\x05stub2\x05stub3\x04\ +\0\x0aedge-label\x03\0\x02\x01m\x04\x07skipped\x05stub1\x05stub2\x05stub3\x04\0\x0d\ +terminal-kind\x03\0\x04\x04\0\x08language\x03\x01\x04\0\x0bparse-error\x03\x01\x04\ +\0\x0cparse-output\x03\x01\x04\0\x10nonterminal-node\x03\x01\x04\0\x0dterminal-n\ +ode\x03\x01\x01i\x09\x01i\x0a\x01q\x02\x0bnonterminal\x01\x0b\0\x08terminal\x01\x0c\ +\0\x04\0\x04node\x03\0\x0d\x04\0\x06cursor\x03\x01\x04\0\x05query\x03\x01\x01r\x03\ +\x07messages\x04liney\x06columny\x04\0\x0bquery-error\x03\0\x11\x01i\x0f\x01p\x13\ +\x01o\x02s\x14\x01p\x15\x01r\x02\x0cquery-numbery\x08captures\x16\x04\0\x0bquery\ +-match\x03\0\x17\x04\0\x14query-match-iterator\x03\x01\x01m\x04\x05error\x07warn\ +ing\x0binformation\x04hint\x04\0\x08severity\x03\0\x1a\x01r\x04\x04utf8y\x05utf1\ +6y\x04liney\x06columny\x04\0\x0atext-index\x03\0\x1c\x01r\x02\x05start\x1d\x03en\ +d\x1d\x04\0\x0atext-range\x03\0\x1e\x01ps\x01@\0\0\x20\x04\0#[static]language.su\ +pported-versions\x01!\x01i\x06\x01j\x01\"\x01s\x01@\x01\x07versions\0#\x04\0\x14\ +[static]language.new\x01$\x01h\x06\x01@\x01\x04self%\0s\x04\0\x18[method]languag\ +e.version\x01&\x01i\x08\x01@\x03\x04self%\x04kind\x01\x05inputs\0'\x04\0\x16[met\ +hod]language.parse\x01(\x01h\x07\x01@\x01\x04self)\0\x1b\x04\0\x1c[method]parse-\ +error.severity\x01*\x01@\x01\x04self)\0\x1f\x04\0\x1e[method]parse-error.text-ra\ +nge\x01+\x01@\x01\x04self)\0s\x04\0\x1b[method]parse-error.message\x01,\x01h\x08\ +\x01@\x01\x04self-\0\x0e\x04\0\x19[method]parse-output.tree\x01.\x01i\x07\x01p/\x01\ +@\x01\x04self-\00\x04\0\x1b[method]parse-output.errors\x011\x01@\x01\x04self-\0\x7f\ +\x04\0\x1d[method]parse-output.is-valid\x012\x01@\x01\x04self-\0\x13\x04\0'[meth\ +od]parse-output.create-tree-cursor\x013\x01h\x09\x01@\x01\x04self4\0\x01\x04\0\x1d\ +[method]nonterminal-node.kind\x015\x01@\x01\x04self4\0\x1d\x04\0![method]nonterm\ +inal-node.text-len\x016\x01p\x0e\x01@\x01\x04self4\07\x04\0![method]nonterminal-\ +node.children\x018\x01@\x02\x04self4\x0btext-offset\x1d\0\x13\x04\0&[method]nont\ +erminal-node.create-cursor\x019\x01@\x01\x04self4\0s\x04\0\x20[method]nontermina\ +l-node.unparse\x01:\x01h\x0a\x01@\x01\x04self;\0\x05\x04\0\x1a[method]terminal-n\ +ode.kind\x01<\x01@\x01\x04self;\0\x1d\x04\0\x1e[method]terminal-node.text-len\x01\ +=\x01@\x01\x04self;\0s\x04\0\x1a[method]terminal-node.text\x01>\x01h\x0f\x01@\x01\ +\x04self?\x01\0\x04\0\x14[method]cursor.reset\x01@\x04\0\x17[method]cursor.compl\ +ete\x01@\x01@\x01\x04self?\0\x7f\x04\0\x1b[method]cursor.is-completed\x01A\x01@\x01\ +\x04self?\0\x13\x04\0\x14[method]cursor.clone\x01B\x04\0\x14[method]cursor.spawn\ +\x01B\x01@\x01\x04self?\0\x0e\x04\0\x13[method]cursor.node\x01C\x01k\x03\x01@\x01\ +\x04self?\0\xc4\0\x04\0\x14[method]cursor.label\x01E\x01@\x01\x04self?\0\x1d\x04\ +\0\x1a[method]cursor.text-offset\x01F\x01@\x01\x04self?\0\x1f\x04\0\x19[method]c\ +ursor.text-range\x01G\x01@\x01\x04self?\0y\x04\0\x14[method]cursor.depth\x01H\x01\ +p\x0b\x01@\x01\x04self?\0\xc9\0\x04\0\x18[method]cursor.ancestors\x01J\x04\0\x19\ +[method]cursor.go-to-next\x01A\x04\0([method]cursor.go-to-next-non-descendent\x01\ +A\x04\0\x1d[method]cursor.go-to-previous\x01A\x04\0\x1b[method]cursor.go-to-pare\ +nt\x01A\x04\0\x20[method]cursor.go-to-first-child\x01A\x04\0\x1f[method]cursor.g\ +o-to-last-child\x01A\x01@\x02\x04self?\x0cchild-numbery\0\x7f\x04\0\x1e[method]c\ +ursor.go-to-nth-child\x01K\x04\0![method]cursor.go-to-next-sibling\x01A\x04\0%[m\ +ethod]cursor.go-to-previous-sibling\x01A\x04\0\"[method]cursor.go-to-next-termin\ +al\x01A\x01@\x02\x04self?\x04kind\x05\0\x7f\x04\0,[method]cursor.go-to-next-term\ +inal-with-kind\x01L\x01p\x05\x01@\x02\x04self?\x05kinds\xcd\0\0\x7f\x04\0-[metho\ +d]cursor.go-to-next-terminal-with-kinds\x01N\x04\0%[method]cursor.go-to-next-non\ +terminal\x01A\x01@\x02\x04self?\x04kind\x01\0\x7f\x04\0/[method]cursor.go-to-nex\ +t-nonterminal-with-kind\x01O\x01p\x01\x01@\x02\x04self?\x05kinds\xd0\0\0\x7f\x04\ +\00[method]cursor.go-to-next-nonterminal-with-kinds\x01Q\x01h\x10\x01p\xd2\0\x01\ +i\x19\x01@\x02\x04self?\x07queries\xd3\0\0\xd4\0\x04\0\x14[method]cursor.query\x01\ +U\x01i\x10\x01j\x01\xd6\0\x01\x12\x01@\x01\x04texts\0\xd7\0\x04\0\x13[static]que\ +ry.parse\x01X\x01h\x19\x01k\x18\x01@\x01\x04self\xd9\0\0\xda\0\x04\0![method]que\ +ry-match-iterator.next\x01[\x04\x01\x18nomic:slang/parser@1.0.0\x05\0\x04\x01\x17\ +nomic:slang/slang@1.0.0\x04\0\x0b\x0b\x01\0\x05slang\x03\0\0\0G\x09producers\x01\ +\x0cprocessed-by\x02\x0dwit-component\x070.209.1\x10wit-bindgen-rust\x060.26.0"; + }; + ) +} +#[doc(inline)] +pub use __export_slang_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.26.0:slang-with-all-of-its-exports-removed:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 221] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07B\x01A\x02\x01A\0\x04\ +\x017nomic:slang/slang-with-all-of-its-exports-removed@1.0.0\x04\0\x0b+\x01\0%sl\ +ang-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.209.1\x10wit-bindgen-rust\x060.26.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen::rt::maybe_link_cabi_realloc(); +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.wit b/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.wit new file mode 100644 index 0000000000..889e543ef7 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/generated/slang.wit @@ -0,0 +1,164 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +package nomic:slang@1.0.0; + +world slang { + export parser; +} + +interface parser { + + enum nonterminal-kind { + stub1, + stub2, + stub3, + } + + enum edge-label { + // Built-in: + %item, + %variant, + %separator, + %operand, + %left-operand, + %right-operand, + %leading-trivia, + %trailing-trivia, + + // Generated: + stub1, + stub2, + stub3, + } + + enum terminal-kind { + // Built-in: + skipped, + + // Generated: + stub1, + stub2, + stub3, + } + + resource language { + supported-versions: static func() -> list; + new: static func(version: string) -> result; + version: func() -> string; + parse: func(kind: nonterminal-kind, input: string) -> parse-output; + } + + resource parse-error { + // is-a diagnostic + severity: func() -> severity; + text-range: func() -> text-range; + message: func() -> string; + } + + resource parse-output { + tree: func() -> node; + errors: func() -> list; + is-valid: func() -> bool; + create-tree-cursor: func() -> cursor; + } + + variant node { + nonterminal(nonterminal-node), + terminal(terminal-node) + } + + resource nonterminal-node { + kind: func() -> nonterminal-kind; + text-len: func() -> text-index; + children: func() -> list; + create-cursor: func(text-offset: text-index) -> cursor; + unparse: func() -> string; + } + + resource terminal-node { + kind: func() -> terminal-kind; + text-len: func() -> text-index; + text: func() -> string; + } + + resource cursor { + reset: func(); + complete: func(); + is-completed: func() -> bool; + + clone: func() -> cursor; + spawn: func() -> cursor; + + node: func() -> node; + label: func() -> option; + + text-offset: func() -> text-index; + text-range: func() -> text-range; + + depth: func() -> u32; + + ancestors: func() -> list; + + go-to-next: func() -> bool; + go-to-next-non-descendent: func() -> bool; + go-to-previous: func() -> bool; + + go-to-parent: func() -> bool; + + go-to-first-child: func() -> bool; + go-to-last-child: func() -> bool; + go-to-nth-child: func(child-number: u32) -> bool; + + go-to-next-sibling: func() -> bool; + go-to-previous-sibling: func() -> bool; + + go-to-next-terminal: func() -> bool; + go-to-next-terminal-with-kind: func(kind: terminal-kind) -> bool; + go-to-next-terminal-with-kinds: func(kinds: list) -> bool; + + go-to-next-nonterminal: func() -> bool; + go-to-next-nonterminal-with-kind: func(kind: nonterminal-kind) -> bool; + go-to-next-nonterminal-with-kinds: func(kinds: list) -> bool; + + query: func(queries: list>) -> query-match-iterator; + } + + resource query { + parse: static func(text: string) -> result; + } + + record query-error { + message: string, + line: u32, + column: u32, + } + + record query-match { + query-number: u32, + captures: list>>, + } + + resource query-match-iterator { + next: func() -> option; + } + + enum severity { + error, + warning, + information, + hint, + } + + record text-index { + utf8: u32, + utf16: u32, + line: u32, + column: u32, + } + + record text-range { + start: text-index, + end: text-index, + } + +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/kinds.rs b/crates/codegen/runtime/cargo/src/runtime/wit/kinds.rs new file mode 100644 index 0000000000..af1bee2aed --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/kinds.rs @@ -0,0 +1,25 @@ +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum nonterminal-kind +// +//================================================ + +enum_to_enum!(NonterminalKind); + +//================================================ +// +// enum terminal-kind +// +//================================================ + +enum_to_enum!(TerminalKind); + +//================================================ +// +// enum edge-label +// +//================================================ + +enum_to_enum!(EdgeLabel); diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/language.rs b/crates/codegen/runtime/cargo/src/runtime/wit/language.rs new file mode 100644 index 0000000000..98ac1686cd --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/language.rs @@ -0,0 +1,77 @@ +use super::{define_wrapper, ffi, rust, FromFFI, IntoFFI}; + +use rust::Diagnostic as _; + +//================================================ +// +// resource language +// +//================================================ + +define_wrapper! { Language { + fn new(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid version: {version}")) + .and_then(|version| rust::Language::new(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + + fn supported_versions() -> Vec { + rust::Language::SUPPORTED_VERSIONS + .iter() + .map(|v| v.to_string()) + .collect() + } + + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { + self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() + } +} } + +//================================================ +// +// resource parse-error +// +//================================================ + +define_wrapper! { ParseError { + fn severity(&self) -> ffi::Severity { + self._borrow_ffi().severity()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + fn message(&self) -> String { + self._borrow_ffi().message() + } +} } + +//================================================ +// +// resource parse-output +// +//================================================ + +define_wrapper! { ParseOutput { + fn tree(&self) -> ffi::Node { + self._borrow_ffi().tree()._into_ffi() + } + + fn errors(&self) -> Vec { + self._borrow_ffi().errors().iter().map(|e| e.clone()._into_ffi()).collect() + } + + fn is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } + + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } +} } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs b/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs new file mode 100644 index 0000000000..859d45ea3b --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs @@ -0,0 +1,246 @@ +pub mod cst; +pub mod cursor; +pub mod diagnostic; +pub mod kinds; +pub mod language; +pub mod query; +pub mod text_index; + +#[path = "generated/slang.rs"] +pub mod slang; + +// #[path = "generated/ast_selectors.rs"] +// pub mod ast_selectors; + +pub mod ffi { + pub use crate::wit::slang::exports::nomic::slang::parser::{ + Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestLanguage, GuestNonterminalNode, + GuestParseError, GuestParseOutput, GuestQuery, GuestQueryMatchIterator, GuestTerminalNode, + Language, LanguageBorrow, Node, NonterminalKind, NonterminalNode, NonterminalNodeBorrow, + ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Query, QueryBorrow, + QueryError, QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, Severity, + TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, TextRange, + }; +} + +pub mod rust { + pub use crate::{ + cst::{Edge, Node, NonterminalNode, TerminalNode}, + cursor::Cursor, + diagnostic::{Diagnostic, Severity}, + kinds::{EdgeLabel, NonterminalKind, TerminalKind}, + language::Language, + parse_error::ParseError, + parse_output::ParseOutput, + query::{Query, QueryError, QueryMatch, QueryMatchIterator}, + text_index::{TextIndex, TextRange}, + }; +} + +pub trait IntoFFI { + fn _into_ffi(self) -> F; +} + +pub trait FromFFI { + fn _from_ffi(self) -> R; +} + +macro_rules! define_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (rust::$name); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&'a self) -> &'a rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_rc_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::rc::Rc); + + impl $crate::wit::IntoFFI for std::rc::Rc { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI> for ffi::$name { + #[inline] + fn _from_ffi(self) -> std::rc::Rc { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_refcell_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::cell::RefCell); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0.into_inner() + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.0.borrow() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.0.borrow_mut() + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! enum_to_enum { + ($name:ident) => { + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + unsafe { core::mem::transmute(self) } + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + unsafe { core::mem::transmute(self) } + } + } + }; +} + +// The trick: https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files +pub(crate) use {define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum}; + +#[allow(clippy::upper_case_acronyms)] +pub struct API; + +//================================================ +// +// interface language +// +//================================================ + +impl ffi::Guest for API { + type Language = language::LanguageWrapper; + type ParseError = language::ParseErrorWrapper; + type ParseOutput = language::ParseOutputWrapper; + type NonterminalNode = cst::NonterminalNodeWrapper; + type TerminalNode = cst::TerminalNodeWrapper; + type Cursor = cursor::CursorWrapper; + type Query = query::QueryWrapper; + type QueryMatchIterator = query::QueryMatchIteratorWrapper; +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/query.rs b/crates/codegen/runtime/cargo/src/runtime/wit/query.rs new file mode 100644 index 0000000000..a2bc62dc35 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/query.rs @@ -0,0 +1,64 @@ +use super::{define_refcell_wrapper, define_wrapper, ffi, rust, IntoFFI}; + +//================================================ +// +// resource query +// +//================================================ + +define_wrapper! { Query { + fn parse(text: String) -> Result { + rust::Query::parse(&text).map_err(IntoFFI::_into_ffi).map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-error +// +//================================================ + +impl IntoFFI for rust::QueryError { + #[inline] + fn _into_ffi(self) -> ffi::QueryError { + #[allow(clippy::cast_possible_truncation)] + ffi::QueryError { + message: self.message, + line: self.line as u32, + column: self.column as u32, + } + } +} + +//================================================ +// +// resource query-match-iterator +// +//================================================ + +define_refcell_wrapper! { QueryMatchIterator { + fn next(&self) -> Option { + self._borrow_mut_ffi().next().map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-match +// +//================================================ + +impl IntoFFI for rust::QueryMatch { + #[inline] + fn _into_ffi(self) -> ffi::QueryMatch { + ffi::QueryMatch { + #[allow(clippy::cast_possible_truncation)] + query_number: self.query_number as u32, + captures: self + .captures + .into_iter() + .map(|(k, v)| (k, v.into_iter().map(|c| c._into_ffi()).collect())) + .collect(), + } + } +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/slang.wit.jinja2 b/crates/codegen/runtime/cargo/src/runtime/wit/slang.wit.jinja2 new file mode 100644 index 0000000000..23b46d3a7b --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/slang.wit.jinja2 @@ -0,0 +1,175 @@ +package nomic:slang@1.0.0; + +world slang { + export parser; +} + +interface parser { + + enum nonterminal-kind { + {%- if rendering_in_stubs %} + stub1, + stub2, + stub3, + {%- else %} + {%- for variant in model.kinds.nonterminal_kinds %} + {{ variant | wit_identifier }}, + {%- endfor %} + {%- endif %} + } + + enum edge-label { + // Built-in: + {%- for label in model.kinds.built_in_labels %} + {{ label | wit_identifier }}, + {%- endfor %} + + // Generated: + {%- if rendering_in_stubs %} + stub1, + stub2, + stub3, + {%- else %} + {%- for variant in model.kinds.labels %} + {{ variant | wit_identifier }}, + {%- endfor %} + {%- endif %} + } + + enum terminal-kind { + // Built-in: + skipped, + + // Generated: + {%- if rendering_in_stubs %} + stub1, + stub2, + stub3, + {%- else %} + {%- for variant in model.kinds.terminal_kinds %} + {{ variant | wit_identifier}}, + {%- endfor %} + {%- endif %} + } + + resource language { + supported-versions: static func() -> list; + new: static func(version: string) -> result; + version: func() -> string; + parse: func(kind: nonterminal-kind, input: string) -> parse-output; + } + + resource parse-error { + // is-a diagnostic + severity: func() -> severity; + text-range: func() -> text-range; + message: func() -> string; + } + + resource parse-output { + tree: func() -> node; + errors: func() -> list; + is-valid: func() -> bool; + create-tree-cursor: func() -> cursor; + } + + variant node { + nonterminal(nonterminal-node), + terminal(terminal-node) + } + + resource nonterminal-node { + kind: func() -> nonterminal-kind; + text-len: func() -> text-index; + children: func() -> list; + create-cursor: func(text-offset: text-index) -> cursor; + unparse: func() -> string; + } + + resource terminal-node { + kind: func() -> terminal-kind; + text-len: func() -> text-index; + text: func() -> string; + } + + resource cursor { + reset: func(); + complete: func(); + is-completed: func() -> bool; + + clone: func() -> cursor; + spawn: func() -> cursor; + + node: func() -> node; + label: func() -> option; + + text-offset: func() -> text-index; + text-range: func() -> text-range; + + depth: func() -> u32; + + ancestors: func() -> list; + + go-to-next: func() -> bool; + go-to-next-non-descendent: func() -> bool; + go-to-previous: func() -> bool; + + go-to-parent: func() -> bool; + + go-to-first-child: func() -> bool; + go-to-last-child: func() -> bool; + go-to-nth-child: func(child-number: u32) -> bool; + + go-to-next-sibling: func() -> bool; + go-to-previous-sibling: func() -> bool; + + go-to-next-terminal: func() -> bool; + go-to-next-terminal-with-kind: func(kind: terminal-kind) -> bool; + go-to-next-terminal-with-kinds: func(kinds: list) -> bool; + + go-to-next-nonterminal: func() -> bool; + go-to-next-nonterminal-with-kind: func(kind: nonterminal-kind) -> bool; + go-to-next-nonterminal-with-kinds: func(kinds: list) -> bool; + + query: func(queries: list>) -> query-match-iterator; + } + + resource query { + parse: static func(text: string) -> result; + } + + record query-error { + message: string, + line: u32, + column: u32, + } + + record query-match { + query-number: u32, + captures: list>>, + } + + resource query-match-iterator { + next: func() -> option; + } + + enum severity { + error, + warning, + information, + hint, + } + + record text-index { + utf8: u32, + utf16: u32, + line: u32, + column: u32, + } + + record text-range { + start: text-index, + end: text-index, + } + +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/text_index.rs b/crates/codegen/runtime/cargo/src/runtime/wit/text_index.rs new file mode 100644 index 0000000000..35a5ae68f9 --- /dev/null +++ b/crates/codegen/runtime/cargo/src/runtime/wit/text_index.rs @@ -0,0 +1,75 @@ +use super::{ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// record text-index +// +//================================================ + +impl IntoFFI for rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + #[allow(clippy::cast_possible_truncation)] + ffi::TextIndex { + utf8: self.utf8 as u32, + utf16: self.utf16 as u32, + line: self.line as u32, + column: self.column as u32, + } + } +} + +impl IntoFFI for &rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + (*self)._into_ffi() + } +} + +impl FromFFI for ffi::TextIndex { + #[inline] + fn _from_ffi(self) -> rust::TextIndex { + rust::TextIndex { + utf8: self.utf8 as usize, + utf16: self.utf16 as usize, + line: self.line as usize, + column: self.column as usize, + } + } +} + +//================================================ +// +// record text-range +// +//================================================ + +impl IntoFFI for rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl IntoFFI for &rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl FromFFI for ffi::TextRange { + #[inline] + fn _from_ffi(self) -> rust::TextRange { + rust::TextRange { + start: self.start._from_ffi(), + end: self.end._from_ffi(), + } + } +} diff --git a/crates/codegen/runtime/generator/Cargo.toml b/crates/codegen/runtime/generator/Cargo.toml index 07ea3ec029..0e729750ec 100644 --- a/crates/codegen/runtime/generator/Cargo.toml +++ b/crates/codegen/runtime/generator/Cargo.toml @@ -17,7 +17,7 @@ proc-macro2 = { workspace = true } quote = { workspace = true } semver = { workspace = true } serde = { workspace = true } -strum_macros = { workspace = true } +strum = { workspace = true } [lints] workspace = true diff --git a/crates/codegen/runtime/generator/src/kinds.rs b/crates/codegen/runtime/generator/src/kinds.rs index 3d157ba90f..8b53dd95e4 100644 --- a/crates/codegen/runtime/generator/src/kinds.rs +++ b/crates/codegen/runtime/generator/src/kinds.rs @@ -1,9 +1,10 @@ use std::collections::BTreeSet; -use codegen_language_definition::model::{self, Identifier, Item}; +use codegen_language_definition::model::{self, BuiltInLabel, Identifier, Item}; use serde::Serialize; +use strum::VariantNames; -#[derive(Default, Serialize)] +#[derive(Serialize)] pub struct KindsModel { /// Defines the `NonterminalKind` enum variants. nonterminal_kinds: BTreeSet, @@ -13,10 +14,25 @@ pub struct KindsModel { trivia_scanner_names: BTreeSet, /// Defines `EdgeLabel` enum variants. labels: BTreeSet, + /// Built-in labels for edges + built_in_labels: &'static [&'static str], // Defines the `LexicalContext(Type)` enum and type-level variants. lexical_contexts: BTreeSet, } +impl Default for KindsModel { + fn default() -> Self { + Self { + nonterminal_kinds: BTreeSet::default(), + terminal_kinds: BTreeSet::default(), + trivia_scanner_names: BTreeSet::default(), + labels: BTreeSet::default(), + built_in_labels: BuiltInLabel::VARIANTS, + lexical_contexts: BTreeSet::default(), + } + } +} + impl KindsModel { pub fn create(language: &model::Language) -> Self { let terminal_kinds = language @@ -93,6 +109,7 @@ impl KindsModel { trivia_scanner_names, labels, lexical_contexts, + ..Self::default() } } } diff --git a/crates/codegen/runtime/generator/src/lib.rs b/crates/codegen/runtime/generator/src/lib.rs index b74b1c8d9f..641d4b143d 100644 --- a/crates/codegen/runtime/generator/src/lib.rs +++ b/crates/codegen/runtime/generator/src/lib.rs @@ -5,6 +5,7 @@ use anyhow::Result; use codegen_language_definition::model::Language; use infra_utils::cargo::CargoWorkspace; use infra_utils::codegen::CodegenTemplates; +use infra_utils::commands::Command; use serde::Serialize; use crate::model::RuntimeModel; @@ -25,14 +26,14 @@ pub enum OutputLanguage { #[derive(Serialize)] struct ModelWrapper { rendering_in_stubs: bool, - model: Option, + model: RuntimeModel, } impl OutputLanguage { pub fn generate_runtime(&self, language: &Rc, output_dir: &Path) -> Result<()> { let model = ModelWrapper { rendering_in_stubs: false, - model: Some(RuntimeModel::from_language(language)), + model: RuntimeModel::from_language(language), }; let mut templates = CodegenTemplates::new(self.source_dir()?)?; @@ -43,7 +44,7 @@ impl OutputLanguage { pub fn generate_stubs(&self) -> Result<()> { let model = ModelWrapper { rendering_in_stubs: true, - model: None, + model: RuntimeModel::default(), }; let mut templates = CodegenTemplates::new(self.source_dir()?)?; @@ -51,6 +52,19 @@ impl OutputLanguage { templates.render_stubs(&model) } + pub fn wit_bindgen(&self, dir: &Path) -> Result<()> { + CargoWorkspace::install_binary("wit-bindgen-cli")?; + Command::new("wit-bindgen") + .arg("rust") + .arg(dir.join("wit/generated/").to_str().unwrap()) + .flag("--rustfmt") + .flag("--pub-export-macro") + .property("--default-bindings-module", "$crate::wit::slang") + .property("--out-dir", dir.join("wit/generated/").to_str().unwrap()) + .run()?; + Ok(()) + } + fn source_dir(&self) -> Result { let crate_name = match self { Self::Cargo => "codegen_runtime_cargo", diff --git a/crates/codegen/runtime/generator/src/model.rs b/crates/codegen/runtime/generator/src/model.rs index 308d8e8845..cdc806110a 100644 --- a/crates/codegen/runtime/generator/src/model.rs +++ b/crates/codegen/runtime/generator/src/model.rs @@ -13,6 +13,7 @@ use crate::parser::ParserModel; pub struct RuntimeModel { /// Defines the `Language::SUPPORTED_VERSIONS` field. all_versions: BTreeSet, + breaking_versions: BTreeSet, parser: ParserModel, ast: AstModel, kinds: KindsModel, @@ -22,6 +23,7 @@ impl RuntimeModel { pub fn from_language(language: &Rc) -> Self { Self { all_versions: language.versions.iter().cloned().collect(), + breaking_versions: language.collect_breaking_versions(), ast: AstModel::create(language), parser: ParserModel::from_language(language), kinds: KindsModel::create(language), diff --git a/crates/codegen/runtime/generator/src/parser.rs b/crates/codegen/runtime/generator/src/parser.rs index 8a2c42e847..637480f055 100644 --- a/crates/codegen/runtime/generator/src/parser.rs +++ b/crates/codegen/runtime/generator/src/parser.rs @@ -3,8 +3,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::rc::Rc; -use codegen_language_definition::model::{Identifier, Language, VersionSpecifier}; -use semver::Version; +use codegen_language_definition::model::{Identifier, Language}; use serde::Serialize; mod codegen; @@ -16,8 +15,8 @@ use codegen::{ }; use grammar::{ Grammar, GrammarVisitor, KeywordScannerAtomic, KeywordScannerDefinitionRef, - ParserDefinitionNode, ParserDefinitionRef, PrecedenceParserDefinitionRef, - ScannerDefinitionNode, ScannerDefinitionRef, TriviaParserDefinitionRef, + ParserDefinitionNode, ParserDefinitionRef, PrecedenceParserDefinitionRef, ScannerDefinitionRef, + TriviaParserDefinitionRef, }; /// Newtype for the already generated Rust code, not to be confused with regular strings. @@ -26,9 +25,6 @@ struct RustCode(String); #[derive(Default, Serialize)] pub struct ParserModel { - /// Constructs inner `Language` the state to evaluate the version-dependent branches. - referenced_versions: BTreeSet, - /// Defines the top-level scanner functions in `Language`. scanner_functions: BTreeMap, // (name of scanner, code) // Defines the `Lexer::next_terminal` method. @@ -61,9 +57,6 @@ struct ScannerContextModel { #[derive(Default)] struct ParserAccumulatorState { - /// Constructs inner `Language` the state to evaluate the version-dependent branches. - referenced_versions: BTreeSet, - // Defines the `Lexer::next_terminal` method. scanner_contexts: BTreeMap, @@ -192,7 +185,6 @@ impl ParserAccumulatorState { .collect(); ParserModel { - referenced_versions: self.referenced_versions, parser_functions: self.parser_functions, trivia_parser_functions: self.trivia_parser_functions, // These are derived from the accumulated state @@ -209,15 +201,6 @@ impl GrammarVisitor for ParserAccumulatorState { .insert(scanner.name().clone(), Rc::clone(scanner)); } - fn keyword_scanner_definition_enter(&mut self, scanner: &KeywordScannerDefinitionRef) { - for def in scanner.definitions() { - let specifiers = def.enabled.iter().chain(def.reserved.iter()); - - self.referenced_versions - .extend(specifiers.flat_map(VersionSpecifier::versions).cloned()); - } - } - fn trivia_parser_definition_enter(&mut self, parser: &TriviaParserDefinitionRef) { self.set_current_context(parser.context().clone()); @@ -254,19 +237,8 @@ impl GrammarVisitor for ParserAccumulatorState { ); } - fn scanner_definition_node_enter(&mut self, node: &ScannerDefinitionNode) { - if let ScannerDefinitionNode::Versioned(_, version_specifier) = node { - self.referenced_versions - .extend(version_specifier.versions().cloned()); - } - } - fn parser_definition_node_enter(&mut self, node: &ParserDefinitionNode) { match node { - ParserDefinitionNode::Versioned(_, version_specifier) => { - self.referenced_versions - .extend(version_specifier.versions().cloned()); - } ParserDefinitionNode::ScannerDefinition(scanner) => { self.top_level_scanner_names.insert(scanner.name().clone()); diff --git a/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs b/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs index 7b22ac1d6c..4e90b88044 100644 --- a/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs +++ b/crates/codegen/runtime/generator/src/parser/grammar/constructor.rs @@ -5,7 +5,9 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::ops::Deref; use std::rc::Rc; -use codegen_language_definition::model::{self, FieldsErrorRecovery, Identifier, Item}; +use codegen_language_definition::model::{ + self, BuiltInLabel, FieldsErrorRecovery, Identifier, Item, +}; use indexmap::IndexMap; use once_cell::sync::Lazy; @@ -793,21 +795,6 @@ trait LabeledExt { fn with_builtin_label(name: BuiltInLabel, node: T) -> Self; } -#[allow(dead_code)] -#[derive(strum_macros::AsRefStr)] -#[strum(serialize_all = "snake_case")] -enum BuiltInLabel { - // _SLANG_INTERNAL_RESERVED_NODE_LABELS_ (keep in sync) - Item, - Variant, - Separator, - Operand, - LeftOperand, - RightOperand, - LeadingTrivia, - TrailingTrivia, -} - impl LabeledExt for Labeled { fn anonymous(value: T) -> Self { Self { diff --git a/crates/infra/utils/src/codegen/formatting.rs b/crates/infra/utils/src/codegen/formatting.rs index 469f3e2636..ae741f750b 100644 --- a/crates/infra/utils/src/codegen/formatting.rs +++ b/crates/infra/utils/src/codegen/formatting.rs @@ -28,7 +28,7 @@ fn generate_header(file_path: &Path) -> String { "ebnf" => format!("(* {warning_line} *)"), "json" => String::new(), "html" | "md" => format!(""), - "js" | "rs" | "ts" => format!("// {warning_line}"), + "js" | "rs" | "ts" | "wit" => format!("// {warning_line}"), "yml" => format!("# {warning_line}"), ext => panic!("Unsupported extension to generate a header for: {ext}"), }; @@ -52,7 +52,7 @@ fn run_formatter(file_path: &Path, contents: &str) -> Result { // We already generate formatted content for these, so no need to run expensive formatting. Ok(contents.to_owned()) } - "ebnf" => { + "ebnf" | "wit" => { // No formatters available for these (yet). Ok(contents.to_owned()) } diff --git a/crates/infra/utils/src/codegen/tera.rs b/crates/infra/utils/src/codegen/tera.rs index 7ef5360021..4852abee8e 100644 --- a/crates/infra/utils/src/codegen/tera.rs +++ b/crates/infra/utils/src/codegen/tera.rs @@ -24,6 +24,9 @@ pub fn create_tera_instance(input_dir: &Path) -> Result { instance.register_filter("camel_case", camel_case_filter); instance.register_filter("pascal_case", pascal_case_filter); instance.register_filter("snake_case", snake_case_filter); + instance.register_filter("kebab_case", kebab_case_filter); + + instance.register_filter("wit_identifier", wit_identifier_filter); instance.register_filter("default_array", default_array_filter); instance.register_filter("default_object", default_object_filter); @@ -68,6 +71,46 @@ fn snake_case_filter(value: &Value, args: &HashMap) -> tera::Resu )) } +fn kebab_case_filter(value: &Value, args: &HashMap) -> tera::Result { + assert_eq!(args.len(), 0, "Expected no arguments"); + + Ok(Value::String( + value + .as_str() + .expect("Expected a string value") + .to_kebab_case(), + )) +} + +fn wit_identifier_filter(value: &Value, args: &HashMap) -> tera::Result { + assert_eq!(args.len(), 0, "Expected no arguments"); + + let input = value.as_str().expect("Expected a string value"); + + let mut result = String::new(); + result.push('%'); + let mut last_was_upper = true; + for c in input.chars() { + if c.is_uppercase() { + if !last_was_upper { + result.push('-'); + } + last_was_upper = true; + for c in c.to_lowercase() { + result.push(c); + } + } else if c.is_alphanumeric() { + last_was_upper = false; + result.push(c); + } else { + last_was_upper = false; + result.push('-'); + } + } + + Ok(Value::String(result)) +} + fn default_array_filter(value: &Value, args: &HashMap) -> tera::Result { assert_eq!(args.len(), 0, "Expected no arguments"); diff --git a/crates/metaslang/cst/src/query/model.rs b/crates/metaslang/cst/src/query/model.rs index 0e074ecded..f6d9f0099c 100644 --- a/crates/metaslang/cst/src/query/model.rs +++ b/crates/metaslang/cst/src/query/model.rs @@ -28,7 +28,7 @@ impl Query { if capture_quantifiers.contains_key(&capture.name) { return Err(QueryError { message: format!("Capture name '{}' used more than once", capture.name), - row: 0, + line: 0, column: 0, }); } @@ -73,7 +73,7 @@ impl Query { return Err(QueryError { message: "Quantification over quantification is not allowed" .to_string(), - row: 0, + line: 0, column: 0, }) } diff --git a/crates/metaslang/cst/src/query/parser.rs b/crates/metaslang/cst/src/query/parser.rs index eade2c431a..c489e67c15 100644 --- a/crates/metaslang/cst/src/query/parser.rs +++ b/crates/metaslang/cst/src/query/parser.rs @@ -23,7 +23,7 @@ use crate::{AbstractKind as _, KindTypes}; #[derive(Clone, Debug, Error)] pub struct QueryError { pub message: String, - pub row: usize, + pub line: usize, pub column: usize, } @@ -43,7 +43,7 @@ pub(super) fn parse_query(input: &str) -> Result, Query .map(|(_, query)| query) .map_err(|e| QueryError { message: e.to_string(), - row: 0, + line: 0, column: 0, }) } diff --git a/crates/metaslang/graph_builder/src/parser.rs b/crates/metaslang/graph_builder/src/parser.rs index 76fedb6aee..628d3ed5b4 100644 --- a/crates/metaslang/graph_builder/src/parser.rs +++ b/crates/metaslang/graph_builder/src/parser.rs @@ -93,7 +93,7 @@ impl std::fmt::Display for DisplayParseErrorPretty<'_> { ParseError::InvalidRegex(_, location) => *location, ParseError::InvalidRegexCapture(location) => *location, ParseError::QueryError(err) => Location { - row: err.row, + row: err.line, column: err.column, }, ParseError::UnexpectedCharacter(_, _, location) => *location, @@ -374,11 +374,11 @@ impl<'a> Parser<'a> { let query = Query::parse(query_source).map_err(|mut e| { // the column of the first row of a query pattern must be shifted by the whitespace // that was already consumed - if e.row == 0 { + if e.line == 0 { // must come before we update e.row! e.column += location.column; } - e.row += location.row; + e.line += location.row; // TODO: we should advance the other offsets, but this parser only tracks utf8 // e.offset += query_start; e diff --git a/crates/metaslang/graph_builder/tests/parser.rs b/crates/metaslang/graph_builder/tests/parser.rs index 0cd8263338..887612cfaa 100644 --- a/crates/metaslang/graph_builder/tests/parser.rs +++ b/crates/metaslang/graph_builder/tests/parser.rs @@ -1558,7 +1558,7 @@ fn query_parse_errors_have_file_location() { Err(ParseError::QueryError(e)) => e, Err(e) => panic!("Unexpected error: {}", e), }; - assert_eq!(err.row, 2, "expected row 2, got {}", err.row); + assert_eq!(err.line, 2, "expected row 2, got {}", err.line); assert_eq!(err.column, 8, "expected column 8, got {}", err.column); // assert_eq!(err.offset, 48, "expected offset 48, got {}", err.offset); } @@ -1579,7 +1579,7 @@ fn multiline_query_parse_errors_have_file_location() { Err(ParseError::QueryError(e)) => e, Err(e) => panic!("Unexpected error: {}", e), }; - assert_eq!(err.row, 3, "expected row 3, got {}", err.row); + assert_eq!(err.line, 3, "expected row 3, got {}", err.line); assert_eq!(err.column, 8, "expected column 8, got {}", err.column); // assert_eq!(err.offset, 112, "expected offset 112, got {}", err.offset); } diff --git a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml index e85f2182b6..b09fad37a0 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml +++ b/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml @@ -34,6 +34,7 @@ required-features = ["cli"] [features] default = ["cli"] cli = ["dep:anyhow", "dep:clap", "dep:serde_json", "__private_ariadne"] +wit = ["dep:wit-bindgen"] # This is meant to be used by the CLI or internally only. __private_ariadne = ["dep:ariadne"] @@ -48,12 +49,14 @@ anyhow = { workspace = true, optional = true } ariadne = { workspace = true, optional = true } clap = { workspace = true, optional = true } metaslang_cst = { workspace = true } +paste = { workspace = true } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true, optional = true } strum = { workspace = true } strum_macros = { workspace = true } thiserror = { workspace = true } +wit-bindgen = { workspace = true, optional = true } [lints] workspace = true diff --git a/crates/solidity/outputs/cargo/slang_solidity/build.rs b/crates/solidity/outputs/cargo/slang_solidity/build.rs index ba7114c8d8..05c75c93d9 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/build.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/build.rs @@ -11,5 +11,7 @@ fn main() -> Result<()> { let output_dir = CargoWorkspace::locate_source_crate("slang_solidity")?.join("src/generated"); - OutputLanguage::Cargo.generate_runtime(&language, &output_dir) + OutputLanguage::Cargo.generate_runtime(&language, &output_dir)?; + OutputLanguage::Cargo.wit_bindgen(&output_dir)?; + Ok(()) } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs index 601b507bdf..073a362fcd 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/kinds.rs @@ -3,6 +3,8 @@ #[cfg(feature = "slang_napi_interfaces")] use napi_derive::napi; +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -238,6 +240,8 @@ pub enum NonterminalKind { impl metaslang_cst::NonterminalKind for NonterminalKind {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -393,6 +397,8 @@ pub enum EdgeLabel { impl metaslang_cst::EdgeLabel for EdgeLabel {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u16)] #[derive( Debug, Eq, @@ -793,6 +799,8 @@ impl metaslang_cst::TerminalKind for TerminalKind { } /// The lexical context of the scanner. +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive(strum_macros::FromRepr, Clone, Copy)] pub(crate) enum LexicalContext { Default, diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs index b397491fff..c30451599b 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/generated/language.rs @@ -31,6 +31,8 @@ use crate::parser_support::{ #[derive(Debug)] #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { + #[allow(dead_code)] + pub(crate) version_is_at_least_0_4_11: bool, pub(crate) version_is_at_least_0_4_12: bool, pub(crate) version_is_at_least_0_4_14: bool, pub(crate) version_is_at_least_0_4_16: bool, @@ -171,6 +173,7 @@ impl Language { pub fn new(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { + version_is_at_least_0_4_11: Version::new(0, 4, 11) <= version, version_is_at_least_0_4_12: Version::new(0, 4, 12) <= version, version_is_at_least_0_4_14: Version::new(0, 4, 14) <= version, version_is_at_least_0_4_16: Version::new(0, 4, 16) <= version, diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs index c444d0844e..19e188473c 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs @@ -12,6 +12,9 @@ pub mod language; pub mod parse_error; pub mod parse_output; +#[cfg(feature = "wit")] +pub mod wit; + #[cfg(feature = "slang_napi_interfaces")] pub mod napi_interface; @@ -65,6 +68,7 @@ pub mod query { pub type Query = query::Query; pub type QueryMatch = query::QueryMatch; pub type QueryMatchIterator = query::QueryMatchIterator; + pub use query::QueryError; } pub mod text_index { diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cst.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cst.rs new file mode 100644 index 0000000000..0fea6d85c4 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cst.rs @@ -0,0 +1,67 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_rc_wrapper, ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// resource nonterminal-node +// +//================================================ + +define_rc_wrapper! { NonterminalNode { + fn kind(&self) -> ffi::NonterminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text_len(&self) -> ffi::TextIndex { + self._borrow_ffi().text_len._into_ffi() + } + + fn children(&self) -> Vec { + todo!() + } + + fn create_cursor(&self, text_offset: ffi::TextIndex) -> ffi::Cursor { + std::rc::Rc::clone(self._borrow_ffi()).cursor_with_offset(text_offset._from_ffi())._into_ffi() + } + + fn unparse(&self) -> String { + std::rc::Rc::clone(self._borrow_ffi()).unparse() + } +} } + +//================================================ +// +// resource terminal-node +// +//================================================ + +define_rc_wrapper! { TerminalNode { + fn kind(&self) -> ffi::TerminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text(&self) -> String { + self._borrow_ffi().text.clone() + } + + fn text_len(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + } +} } + +//================================================ +// +// variant node +// +//================================================ + +impl IntoFFI for rust::Node { + #[inline] + fn _into_ffi(self) -> ffi::Node { + match self { + Self::Nonterminal(node) => ffi::Node::Nonterminal(node._into_ffi()), + Self::Terminal(node) => ffi::Node::Terminal(node._into_ffi()), + } + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cursor.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cursor.rs new file mode 100644 index 0000000000..b9be5d3348 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/cursor.rs @@ -0,0 +1,125 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_refcell_wrapper, ffi, rust, FromFFI, IntoFFI}; +//================================================ +// +// resource cursor +// +//================================================ + +define_refcell_wrapper! { Cursor { + fn reset(&self) { + self._borrow_mut_ffi().reset(); + } + + fn complete(&self) { + self._borrow_mut_ffi().complete(); + } + + fn is_completed(&self) -> bool { + self._borrow_ffi().is_completed() + } + + fn clone(&self) -> ffi::Cursor { + self._borrow_ffi().clone()._into_ffi() + } + + fn spawn(&self) -> ffi::Cursor { + self._borrow_ffi().spawn()._into_ffi() + } + + fn node(&self) -> ffi::Node { + self._borrow_ffi().node()._into_ffi() + } + + fn label(&self) -> Option { + self._borrow_ffi().label().map(IntoFFI::_into_ffi) + } + + fn text_offset(&self) -> ffi::TextIndex { + self._borrow_ffi().text_offset()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + #[allow(clippy::cast_possible_truncation)] + fn depth(&self) -> u32 { + self._borrow_ffi().depth() as u32 + } + + fn ancestors(&self) -> Vec { + self._borrow_ffi().ancestors().map(|x|x._into_ffi()).collect() + } + + fn go_to_next(&self) -> bool { + self._borrow_mut_ffi().go_to_next() + } + + fn go_to_next_non_descendent(&self) -> bool { + self._borrow_mut_ffi().go_to_next_non_descendent() + } + + fn go_to_previous(&self) -> bool { + self._borrow_mut_ffi().go_to_previous() + } + + fn go_to_parent(&self) -> bool { + self._borrow_mut_ffi().go_to_parent() + } + + fn go_to_first_child(&self) -> bool { + self._borrow_mut_ffi().go_to_first_child() + } + + fn go_to_last_child(&self) -> bool { + self._borrow_mut_ffi().go_to_last_child() + } + + fn go_to_nth_child(&self, child_number: u32) -> bool { + self._borrow_mut_ffi().go_to_nth_child(child_number as usize) + } + + fn go_to_next_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_next_sibling() + } + + fn go_to_previous_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_previous_sibling() + } + + fn go_to_next_terminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_terminal() + } + + fn go_to_next_terminal_with_kind(&self, kind: ffi::TerminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_terminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_terminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_terminal_with_kinds(&kinds) + } + + fn go_to_next_nonterminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal() + } + + fn go_to_next_nonterminal_with_kind(&self, kind: ffi::NonterminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_nonterminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_nonterminal_with_kinds(&kinds) + } + + fn query(&self, queries: Vec>) -> ffi::QueryMatchIterator { + let queries:Vec = queries.into_iter().map(|q|{ + q._borrow_ffi().clone() + }).collect(); + + self._borrow_ffi().clone().query(queries)._into_ffi() + } +} } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/diagnostic.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/diagnostic.rs new file mode 100644 index 0000000000..d8c0910196 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/diagnostic.rs @@ -0,0 +1,11 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum severity +// +//================================================ + +enum_to_enum!(Severity); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.rs new file mode 100644 index 0000000000..aff3156006 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.rs @@ -0,0 +1,7182 @@ +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! +// Options used: +// * default-bindings-module: "$crate::wit::slang" +// * pub-export-macro +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod nomic { + #[allow(dead_code)] + pub mod slang { + #[allow(dead_code, clippy::all)] + pub mod parser { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum NonterminalKind { + AbicoderPragma, + AdditiveExpression, + AddressType, + AndExpression, + ArgumentsDeclaration, + ArrayExpression, + ArrayTypeName, + ArrayValues, + AssemblyFlags, + AssemblyFlagsDeclaration, + AssemblyStatement, + AssignmentExpression, + BitwiseAndExpression, + BitwiseOrExpression, + BitwiseXorExpression, + Block, + BreakStatement, + CallOptions, + CallOptionsExpression, + CatchClause, + CatchClauseError, + CatchClauses, + ComparisonExpression, + ConditionalExpression, + ConstantDefinition, + ConstructorAttribute, + ConstructorAttributes, + ConstructorDefinition, + ContinueStatement, + ContractDefinition, + ContractMember, + ContractMembers, + DecimalNumberExpression, + DoWhileStatement, + ElementaryType, + ElseBranch, + EmitStatement, + EnumDefinition, + EnumMembers, + EqualityExpression, + ErrorDefinition, + ErrorParameter, + ErrorParameters, + ErrorParametersDeclaration, + EventDefinition, + EventParameter, + EventParameters, + EventParametersDeclaration, + ExperimentalFeature, + ExperimentalPragma, + ExponentiationExpression, + Expression, + ExpressionStatement, + FallbackFunctionAttribute, + FallbackFunctionAttributes, + FallbackFunctionDefinition, + ForStatement, + ForStatementCondition, + ForStatementInitialization, + FunctionAttribute, + FunctionAttributes, + FunctionBody, + FunctionCallExpression, + FunctionDefinition, + FunctionName, + FunctionType, + FunctionTypeAttribute, + FunctionTypeAttributes, + HexNumberExpression, + HexStringLiteral, + HexStringLiterals, + IdentifierPath, + IfStatement, + ImportAlias, + ImportClause, + ImportDeconstruction, + ImportDeconstructionSymbol, + ImportDeconstructionSymbols, + ImportDirective, + IndexAccessEnd, + IndexAccessExpression, + InheritanceSpecifier, + InheritanceType, + InheritanceTypes, + InterfaceDefinition, + InterfaceMembers, + LibraryDefinition, + LibraryMembers, + MappingKey, + MappingKeyType, + MappingType, + MappingValue, + MemberAccess, + MemberAccessExpression, + ModifierAttribute, + ModifierAttributes, + ModifierDefinition, + ModifierInvocation, + MultiplicativeExpression, + NamedArgument, + NamedArgumentGroup, + NamedArguments, + NamedArgumentsDeclaration, + NamedImport, + NewExpression, + NumberUnit, + OrExpression, + OverridePaths, + OverridePathsDeclaration, + OverrideSpecifier, + Parameter, + Parameters, + ParametersDeclaration, + PathImport, + PositionalArguments, + PositionalArgumentsDeclaration, + PostfixExpression, + Pragma, + PragmaDirective, + PrefixExpression, + ReceiveFunctionAttribute, + ReceiveFunctionAttributes, + ReceiveFunctionDefinition, + ReturnStatement, + ReturnsDeclaration, + RevertStatement, + ShiftExpression, + SourceUnit, + SourceUnitMember, + SourceUnitMembers, + StateVariableAttribute, + StateVariableAttributes, + StateVariableDefinition, + StateVariableDefinitionValue, + Statement, + Statements, + StorageLocation, + StringExpression, + StringLiteral, + StringLiterals, + StructDefinition, + StructMember, + StructMembers, + ThrowStatement, + TryStatement, + TupleDeconstructionElement, + TupleDeconstructionElements, + TupleDeconstructionStatement, + TupleExpression, + TupleMember, + TupleValue, + TupleValues, + TypeExpression, + TypeName, + TypedTupleMember, + UncheckedBlock, + UnicodeStringLiteral, + UnicodeStringLiterals, + UnnamedFunctionAttribute, + UnnamedFunctionAttributes, + UnnamedFunctionDefinition, + UntypedTupleMember, + UserDefinedValueTypeDefinition, + UsingAlias, + UsingClause, + UsingDeconstruction, + UsingDeconstructionSymbol, + UsingDeconstructionSymbols, + UsingDirective, + UsingOperator, + UsingTarget, + VariableDeclarationStatement, + VariableDeclarationType, + VariableDeclarationValue, + VersionComparator, + VersionExpression, + VersionExpressionSet, + VersionExpressionSets, + VersionPragma, + VersionRange, + VersionSpecifiers, + WhileStatement, + YulArguments, + YulAssignmentOperator, + YulBlock, + YulBreakStatement, + YulBuiltInFunction, + YulColonEqual, + YulContinueStatement, + YulDefaultCase, + YulExpression, + YulForStatement, + YulFunctionCallExpression, + YulFunctionDefinition, + YulIfStatement, + YulLabel, + YulLeaveStatement, + YulLiteral, + YulParameters, + YulParametersDeclaration, + YulPath, + YulPathComponent, + YulPaths, + YulReturnVariables, + YulReturnsDeclaration, + YulStackAssignmentStatement, + YulStatement, + YulStatements, + YulSwitchCase, + YulSwitchCases, + YulSwitchStatement, + YulValueCase, + YulVariableAssignmentStatement, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, + } + impl ::core::fmt::Debug for NonterminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + NonterminalKind::AbicoderPragma => { + f.debug_tuple("NonterminalKind::AbicoderPragma").finish() + } + NonterminalKind::AdditiveExpression => f + .debug_tuple("NonterminalKind::AdditiveExpression") + .finish(), + NonterminalKind::AddressType => { + f.debug_tuple("NonterminalKind::AddressType").finish() + } + NonterminalKind::AndExpression => { + f.debug_tuple("NonterminalKind::AndExpression").finish() + } + NonterminalKind::ArgumentsDeclaration => f + .debug_tuple("NonterminalKind::ArgumentsDeclaration") + .finish(), + NonterminalKind::ArrayExpression => { + f.debug_tuple("NonterminalKind::ArrayExpression").finish() + } + NonterminalKind::ArrayTypeName => { + f.debug_tuple("NonterminalKind::ArrayTypeName").finish() + } + NonterminalKind::ArrayValues => { + f.debug_tuple("NonterminalKind::ArrayValues").finish() + } + NonterminalKind::AssemblyFlags => { + f.debug_tuple("NonterminalKind::AssemblyFlags").finish() + } + NonterminalKind::AssemblyFlagsDeclaration => f + .debug_tuple("NonterminalKind::AssemblyFlagsDeclaration") + .finish(), + NonterminalKind::AssemblyStatement => { + f.debug_tuple("NonterminalKind::AssemblyStatement").finish() + } + NonterminalKind::AssignmentExpression => f + .debug_tuple("NonterminalKind::AssignmentExpression") + .finish(), + NonterminalKind::BitwiseAndExpression => f + .debug_tuple("NonterminalKind::BitwiseAndExpression") + .finish(), + NonterminalKind::BitwiseOrExpression => f + .debug_tuple("NonterminalKind::BitwiseOrExpression") + .finish(), + NonterminalKind::BitwiseXorExpression => f + .debug_tuple("NonterminalKind::BitwiseXorExpression") + .finish(), + NonterminalKind::Block => { + f.debug_tuple("NonterminalKind::Block").finish() + } + NonterminalKind::BreakStatement => { + f.debug_tuple("NonterminalKind::BreakStatement").finish() + } + NonterminalKind::CallOptions => { + f.debug_tuple("NonterminalKind::CallOptions").finish() + } + NonterminalKind::CallOptionsExpression => f + .debug_tuple("NonterminalKind::CallOptionsExpression") + .finish(), + NonterminalKind::CatchClause => { + f.debug_tuple("NonterminalKind::CatchClause").finish() + } + NonterminalKind::CatchClauseError => { + f.debug_tuple("NonterminalKind::CatchClauseError").finish() + } + NonterminalKind::CatchClauses => { + f.debug_tuple("NonterminalKind::CatchClauses").finish() + } + NonterminalKind::ComparisonExpression => f + .debug_tuple("NonterminalKind::ComparisonExpression") + .finish(), + NonterminalKind::ConditionalExpression => f + .debug_tuple("NonterminalKind::ConditionalExpression") + .finish(), + NonterminalKind::ConstantDefinition => f + .debug_tuple("NonterminalKind::ConstantDefinition") + .finish(), + NonterminalKind::ConstructorAttribute => f + .debug_tuple("NonterminalKind::ConstructorAttribute") + .finish(), + NonterminalKind::ConstructorAttributes => f + .debug_tuple("NonterminalKind::ConstructorAttributes") + .finish(), + NonterminalKind::ConstructorDefinition => f + .debug_tuple("NonterminalKind::ConstructorDefinition") + .finish(), + NonterminalKind::ContinueStatement => { + f.debug_tuple("NonterminalKind::ContinueStatement").finish() + } + NonterminalKind::ContractDefinition => f + .debug_tuple("NonterminalKind::ContractDefinition") + .finish(), + NonterminalKind::ContractMember => { + f.debug_tuple("NonterminalKind::ContractMember").finish() + } + NonterminalKind::ContractMembers => { + f.debug_tuple("NonterminalKind::ContractMembers").finish() + } + NonterminalKind::DecimalNumberExpression => f + .debug_tuple("NonterminalKind::DecimalNumberExpression") + .finish(), + NonterminalKind::DoWhileStatement => { + f.debug_tuple("NonterminalKind::DoWhileStatement").finish() + } + NonterminalKind::ElementaryType => { + f.debug_tuple("NonterminalKind::ElementaryType").finish() + } + NonterminalKind::ElseBranch => { + f.debug_tuple("NonterminalKind::ElseBranch").finish() + } + NonterminalKind::EmitStatement => { + f.debug_tuple("NonterminalKind::EmitStatement").finish() + } + NonterminalKind::EnumDefinition => { + f.debug_tuple("NonterminalKind::EnumDefinition").finish() + } + NonterminalKind::EnumMembers => { + f.debug_tuple("NonterminalKind::EnumMembers").finish() + } + NonterminalKind::EqualityExpression => f + .debug_tuple("NonterminalKind::EqualityExpression") + .finish(), + NonterminalKind::ErrorDefinition => { + f.debug_tuple("NonterminalKind::ErrorDefinition").finish() + } + NonterminalKind::ErrorParameter => { + f.debug_tuple("NonterminalKind::ErrorParameter").finish() + } + NonterminalKind::ErrorParameters => { + f.debug_tuple("NonterminalKind::ErrorParameters").finish() + } + NonterminalKind::ErrorParametersDeclaration => f + .debug_tuple("NonterminalKind::ErrorParametersDeclaration") + .finish(), + NonterminalKind::EventDefinition => { + f.debug_tuple("NonterminalKind::EventDefinition").finish() + } + NonterminalKind::EventParameter => { + f.debug_tuple("NonterminalKind::EventParameter").finish() + } + NonterminalKind::EventParameters => { + f.debug_tuple("NonterminalKind::EventParameters").finish() + } + NonterminalKind::EventParametersDeclaration => f + .debug_tuple("NonterminalKind::EventParametersDeclaration") + .finish(), + NonterminalKind::ExperimentalFeature => f + .debug_tuple("NonterminalKind::ExperimentalFeature") + .finish(), + NonterminalKind::ExperimentalPragma => f + .debug_tuple("NonterminalKind::ExperimentalPragma") + .finish(), + NonterminalKind::ExponentiationExpression => f + .debug_tuple("NonterminalKind::ExponentiationExpression") + .finish(), + NonterminalKind::Expression => { + f.debug_tuple("NonterminalKind::Expression").finish() + } + NonterminalKind::ExpressionStatement => f + .debug_tuple("NonterminalKind::ExpressionStatement") + .finish(), + NonterminalKind::FallbackFunctionAttribute => f + .debug_tuple("NonterminalKind::FallbackFunctionAttribute") + .finish(), + NonterminalKind::FallbackFunctionAttributes => f + .debug_tuple("NonterminalKind::FallbackFunctionAttributes") + .finish(), + NonterminalKind::FallbackFunctionDefinition => f + .debug_tuple("NonterminalKind::FallbackFunctionDefinition") + .finish(), + NonterminalKind::ForStatement => { + f.debug_tuple("NonterminalKind::ForStatement").finish() + } + NonterminalKind::ForStatementCondition => f + .debug_tuple("NonterminalKind::ForStatementCondition") + .finish(), + NonterminalKind::ForStatementInitialization => f + .debug_tuple("NonterminalKind::ForStatementInitialization") + .finish(), + NonterminalKind::FunctionAttribute => { + f.debug_tuple("NonterminalKind::FunctionAttribute").finish() + } + NonterminalKind::FunctionAttributes => f + .debug_tuple("NonterminalKind::FunctionAttributes") + .finish(), + NonterminalKind::FunctionBody => { + f.debug_tuple("NonterminalKind::FunctionBody").finish() + } + NonterminalKind::FunctionCallExpression => f + .debug_tuple("NonterminalKind::FunctionCallExpression") + .finish(), + NonterminalKind::FunctionDefinition => f + .debug_tuple("NonterminalKind::FunctionDefinition") + .finish(), + NonterminalKind::FunctionName => { + f.debug_tuple("NonterminalKind::FunctionName").finish() + } + NonterminalKind::FunctionType => { + f.debug_tuple("NonterminalKind::FunctionType").finish() + } + NonterminalKind::FunctionTypeAttribute => f + .debug_tuple("NonterminalKind::FunctionTypeAttribute") + .finish(), + NonterminalKind::FunctionTypeAttributes => f + .debug_tuple("NonterminalKind::FunctionTypeAttributes") + .finish(), + NonterminalKind::HexNumberExpression => f + .debug_tuple("NonterminalKind::HexNumberExpression") + .finish(), + NonterminalKind::HexStringLiteral => { + f.debug_tuple("NonterminalKind::HexStringLiteral").finish() + } + NonterminalKind::HexStringLiterals => { + f.debug_tuple("NonterminalKind::HexStringLiterals").finish() + } + NonterminalKind::IdentifierPath => { + f.debug_tuple("NonterminalKind::IdentifierPath").finish() + } + NonterminalKind::IfStatement => { + f.debug_tuple("NonterminalKind::IfStatement").finish() + } + NonterminalKind::ImportAlias => { + f.debug_tuple("NonterminalKind::ImportAlias").finish() + } + NonterminalKind::ImportClause => { + f.debug_tuple("NonterminalKind::ImportClause").finish() + } + NonterminalKind::ImportDeconstruction => f + .debug_tuple("NonterminalKind::ImportDeconstruction") + .finish(), + NonterminalKind::ImportDeconstructionSymbol => f + .debug_tuple("NonterminalKind::ImportDeconstructionSymbol") + .finish(), + NonterminalKind::ImportDeconstructionSymbols => f + .debug_tuple("NonterminalKind::ImportDeconstructionSymbols") + .finish(), + NonterminalKind::ImportDirective => { + f.debug_tuple("NonterminalKind::ImportDirective").finish() + } + NonterminalKind::IndexAccessEnd => { + f.debug_tuple("NonterminalKind::IndexAccessEnd").finish() + } + NonterminalKind::IndexAccessExpression => f + .debug_tuple("NonterminalKind::IndexAccessExpression") + .finish(), + NonterminalKind::InheritanceSpecifier => f + .debug_tuple("NonterminalKind::InheritanceSpecifier") + .finish(), + NonterminalKind::InheritanceType => { + f.debug_tuple("NonterminalKind::InheritanceType").finish() + } + NonterminalKind::InheritanceTypes => { + f.debug_tuple("NonterminalKind::InheritanceTypes").finish() + } + NonterminalKind::InterfaceDefinition => f + .debug_tuple("NonterminalKind::InterfaceDefinition") + .finish(), + NonterminalKind::InterfaceMembers => { + f.debug_tuple("NonterminalKind::InterfaceMembers").finish() + } + NonterminalKind::LibraryDefinition => { + f.debug_tuple("NonterminalKind::LibraryDefinition").finish() + } + NonterminalKind::LibraryMembers => { + f.debug_tuple("NonterminalKind::LibraryMembers").finish() + } + NonterminalKind::MappingKey => { + f.debug_tuple("NonterminalKind::MappingKey").finish() + } + NonterminalKind::MappingKeyType => { + f.debug_tuple("NonterminalKind::MappingKeyType").finish() + } + NonterminalKind::MappingType => { + f.debug_tuple("NonterminalKind::MappingType").finish() + } + NonterminalKind::MappingValue => { + f.debug_tuple("NonterminalKind::MappingValue").finish() + } + NonterminalKind::MemberAccess => { + f.debug_tuple("NonterminalKind::MemberAccess").finish() + } + NonterminalKind::MemberAccessExpression => f + .debug_tuple("NonterminalKind::MemberAccessExpression") + .finish(), + NonterminalKind::ModifierAttribute => { + f.debug_tuple("NonterminalKind::ModifierAttribute").finish() + } + NonterminalKind::ModifierAttributes => f + .debug_tuple("NonterminalKind::ModifierAttributes") + .finish(), + NonterminalKind::ModifierDefinition => f + .debug_tuple("NonterminalKind::ModifierDefinition") + .finish(), + NonterminalKind::ModifierInvocation => f + .debug_tuple("NonterminalKind::ModifierInvocation") + .finish(), + NonterminalKind::MultiplicativeExpression => f + .debug_tuple("NonterminalKind::MultiplicativeExpression") + .finish(), + NonterminalKind::NamedArgument => { + f.debug_tuple("NonterminalKind::NamedArgument").finish() + } + NonterminalKind::NamedArgumentGroup => f + .debug_tuple("NonterminalKind::NamedArgumentGroup") + .finish(), + NonterminalKind::NamedArguments => { + f.debug_tuple("NonterminalKind::NamedArguments").finish() + } + NonterminalKind::NamedArgumentsDeclaration => f + .debug_tuple("NonterminalKind::NamedArgumentsDeclaration") + .finish(), + NonterminalKind::NamedImport => { + f.debug_tuple("NonterminalKind::NamedImport").finish() + } + NonterminalKind::NewExpression => { + f.debug_tuple("NonterminalKind::NewExpression").finish() + } + NonterminalKind::NumberUnit => { + f.debug_tuple("NonterminalKind::NumberUnit").finish() + } + NonterminalKind::OrExpression => { + f.debug_tuple("NonterminalKind::OrExpression").finish() + } + NonterminalKind::OverridePaths => { + f.debug_tuple("NonterminalKind::OverridePaths").finish() + } + NonterminalKind::OverridePathsDeclaration => f + .debug_tuple("NonterminalKind::OverridePathsDeclaration") + .finish(), + NonterminalKind::OverrideSpecifier => { + f.debug_tuple("NonterminalKind::OverrideSpecifier").finish() + } + NonterminalKind::Parameter => { + f.debug_tuple("NonterminalKind::Parameter").finish() + } + NonterminalKind::Parameters => { + f.debug_tuple("NonterminalKind::Parameters").finish() + } + NonterminalKind::ParametersDeclaration => f + .debug_tuple("NonterminalKind::ParametersDeclaration") + .finish(), + NonterminalKind::PathImport => { + f.debug_tuple("NonterminalKind::PathImport").finish() + } + NonterminalKind::PositionalArguments => f + .debug_tuple("NonterminalKind::PositionalArguments") + .finish(), + NonterminalKind::PositionalArgumentsDeclaration => f + .debug_tuple("NonterminalKind::PositionalArgumentsDeclaration") + .finish(), + NonterminalKind::PostfixExpression => { + f.debug_tuple("NonterminalKind::PostfixExpression").finish() + } + NonterminalKind::Pragma => { + f.debug_tuple("NonterminalKind::Pragma").finish() + } + NonterminalKind::PragmaDirective => { + f.debug_tuple("NonterminalKind::PragmaDirective").finish() + } + NonterminalKind::PrefixExpression => { + f.debug_tuple("NonterminalKind::PrefixExpression").finish() + } + NonterminalKind::ReceiveFunctionAttribute => f + .debug_tuple("NonterminalKind::ReceiveFunctionAttribute") + .finish(), + NonterminalKind::ReceiveFunctionAttributes => f + .debug_tuple("NonterminalKind::ReceiveFunctionAttributes") + .finish(), + NonterminalKind::ReceiveFunctionDefinition => f + .debug_tuple("NonterminalKind::ReceiveFunctionDefinition") + .finish(), + NonterminalKind::ReturnStatement => { + f.debug_tuple("NonterminalKind::ReturnStatement").finish() + } + NonterminalKind::ReturnsDeclaration => f + .debug_tuple("NonterminalKind::ReturnsDeclaration") + .finish(), + NonterminalKind::RevertStatement => { + f.debug_tuple("NonterminalKind::RevertStatement").finish() + } + NonterminalKind::ShiftExpression => { + f.debug_tuple("NonterminalKind::ShiftExpression").finish() + } + NonterminalKind::SourceUnit => { + f.debug_tuple("NonterminalKind::SourceUnit").finish() + } + NonterminalKind::SourceUnitMember => { + f.debug_tuple("NonterminalKind::SourceUnitMember").finish() + } + NonterminalKind::SourceUnitMembers => { + f.debug_tuple("NonterminalKind::SourceUnitMembers").finish() + } + NonterminalKind::StateVariableAttribute => f + .debug_tuple("NonterminalKind::StateVariableAttribute") + .finish(), + NonterminalKind::StateVariableAttributes => f + .debug_tuple("NonterminalKind::StateVariableAttributes") + .finish(), + NonterminalKind::StateVariableDefinition => f + .debug_tuple("NonterminalKind::StateVariableDefinition") + .finish(), + NonterminalKind::StateVariableDefinitionValue => f + .debug_tuple("NonterminalKind::StateVariableDefinitionValue") + .finish(), + NonterminalKind::Statement => { + f.debug_tuple("NonterminalKind::Statement").finish() + } + NonterminalKind::Statements => { + f.debug_tuple("NonterminalKind::Statements").finish() + } + NonterminalKind::StorageLocation => { + f.debug_tuple("NonterminalKind::StorageLocation").finish() + } + NonterminalKind::StringExpression => { + f.debug_tuple("NonterminalKind::StringExpression").finish() + } + NonterminalKind::StringLiteral => { + f.debug_tuple("NonterminalKind::StringLiteral").finish() + } + NonterminalKind::StringLiterals => { + f.debug_tuple("NonterminalKind::StringLiterals").finish() + } + NonterminalKind::StructDefinition => { + f.debug_tuple("NonterminalKind::StructDefinition").finish() + } + NonterminalKind::StructMember => { + f.debug_tuple("NonterminalKind::StructMember").finish() + } + NonterminalKind::StructMembers => { + f.debug_tuple("NonterminalKind::StructMembers").finish() + } + NonterminalKind::ThrowStatement => { + f.debug_tuple("NonterminalKind::ThrowStatement").finish() + } + NonterminalKind::TryStatement => { + f.debug_tuple("NonterminalKind::TryStatement").finish() + } + NonterminalKind::TupleDeconstructionElement => f + .debug_tuple("NonterminalKind::TupleDeconstructionElement") + .finish(), + NonterminalKind::TupleDeconstructionElements => f + .debug_tuple("NonterminalKind::TupleDeconstructionElements") + .finish(), + NonterminalKind::TupleDeconstructionStatement => f + .debug_tuple("NonterminalKind::TupleDeconstructionStatement") + .finish(), + NonterminalKind::TupleExpression => { + f.debug_tuple("NonterminalKind::TupleExpression").finish() + } + NonterminalKind::TupleMember => { + f.debug_tuple("NonterminalKind::TupleMember").finish() + } + NonterminalKind::TupleValue => { + f.debug_tuple("NonterminalKind::TupleValue").finish() + } + NonterminalKind::TupleValues => { + f.debug_tuple("NonterminalKind::TupleValues").finish() + } + NonterminalKind::TypeExpression => { + f.debug_tuple("NonterminalKind::TypeExpression").finish() + } + NonterminalKind::TypeName => { + f.debug_tuple("NonterminalKind::TypeName").finish() + } + NonterminalKind::TypedTupleMember => { + f.debug_tuple("NonterminalKind::TypedTupleMember").finish() + } + NonterminalKind::UncheckedBlock => { + f.debug_tuple("NonterminalKind::UncheckedBlock").finish() + } + NonterminalKind::UnicodeStringLiteral => f + .debug_tuple("NonterminalKind::UnicodeStringLiteral") + .finish(), + NonterminalKind::UnicodeStringLiterals => f + .debug_tuple("NonterminalKind::UnicodeStringLiterals") + .finish(), + NonterminalKind::UnnamedFunctionAttribute => f + .debug_tuple("NonterminalKind::UnnamedFunctionAttribute") + .finish(), + NonterminalKind::UnnamedFunctionAttributes => f + .debug_tuple("NonterminalKind::UnnamedFunctionAttributes") + .finish(), + NonterminalKind::UnnamedFunctionDefinition => f + .debug_tuple("NonterminalKind::UnnamedFunctionDefinition") + .finish(), + NonterminalKind::UntypedTupleMember => f + .debug_tuple("NonterminalKind::UntypedTupleMember") + .finish(), + NonterminalKind::UserDefinedValueTypeDefinition => f + .debug_tuple("NonterminalKind::UserDefinedValueTypeDefinition") + .finish(), + NonterminalKind::UsingAlias => { + f.debug_tuple("NonterminalKind::UsingAlias").finish() + } + NonterminalKind::UsingClause => { + f.debug_tuple("NonterminalKind::UsingClause").finish() + } + NonterminalKind::UsingDeconstruction => f + .debug_tuple("NonterminalKind::UsingDeconstruction") + .finish(), + NonterminalKind::UsingDeconstructionSymbol => f + .debug_tuple("NonterminalKind::UsingDeconstructionSymbol") + .finish(), + NonterminalKind::UsingDeconstructionSymbols => f + .debug_tuple("NonterminalKind::UsingDeconstructionSymbols") + .finish(), + NonterminalKind::UsingDirective => { + f.debug_tuple("NonterminalKind::UsingDirective").finish() + } + NonterminalKind::UsingOperator => { + f.debug_tuple("NonterminalKind::UsingOperator").finish() + } + NonterminalKind::UsingTarget => { + f.debug_tuple("NonterminalKind::UsingTarget").finish() + } + NonterminalKind::VariableDeclarationStatement => f + .debug_tuple("NonterminalKind::VariableDeclarationStatement") + .finish(), + NonterminalKind::VariableDeclarationType => f + .debug_tuple("NonterminalKind::VariableDeclarationType") + .finish(), + NonterminalKind::VariableDeclarationValue => f + .debug_tuple("NonterminalKind::VariableDeclarationValue") + .finish(), + NonterminalKind::VersionComparator => { + f.debug_tuple("NonterminalKind::VersionComparator").finish() + } + NonterminalKind::VersionExpression => { + f.debug_tuple("NonterminalKind::VersionExpression").finish() + } + NonterminalKind::VersionExpressionSet => f + .debug_tuple("NonterminalKind::VersionExpressionSet") + .finish(), + NonterminalKind::VersionExpressionSets => f + .debug_tuple("NonterminalKind::VersionExpressionSets") + .finish(), + NonterminalKind::VersionPragma => { + f.debug_tuple("NonterminalKind::VersionPragma").finish() + } + NonterminalKind::VersionRange => { + f.debug_tuple("NonterminalKind::VersionRange").finish() + } + NonterminalKind::VersionSpecifiers => { + f.debug_tuple("NonterminalKind::VersionSpecifiers").finish() + } + NonterminalKind::WhileStatement => { + f.debug_tuple("NonterminalKind::WhileStatement").finish() + } + NonterminalKind::YulArguments => { + f.debug_tuple("NonterminalKind::YulArguments").finish() + } + NonterminalKind::YulAssignmentOperator => f + .debug_tuple("NonterminalKind::YulAssignmentOperator") + .finish(), + NonterminalKind::YulBlock => { + f.debug_tuple("NonterminalKind::YulBlock").finish() + } + NonterminalKind::YulBreakStatement => { + f.debug_tuple("NonterminalKind::YulBreakStatement").finish() + } + NonterminalKind::YulBuiltInFunction => f + .debug_tuple("NonterminalKind::YulBuiltInFunction") + .finish(), + NonterminalKind::YulColonEqual => { + f.debug_tuple("NonterminalKind::YulColonEqual").finish() + } + NonterminalKind::YulContinueStatement => f + .debug_tuple("NonterminalKind::YulContinueStatement") + .finish(), + NonterminalKind::YulDefaultCase => { + f.debug_tuple("NonterminalKind::YulDefaultCase").finish() + } + NonterminalKind::YulExpression => { + f.debug_tuple("NonterminalKind::YulExpression").finish() + } + NonterminalKind::YulForStatement => { + f.debug_tuple("NonterminalKind::YulForStatement").finish() + } + NonterminalKind::YulFunctionCallExpression => f + .debug_tuple("NonterminalKind::YulFunctionCallExpression") + .finish(), + NonterminalKind::YulFunctionDefinition => f + .debug_tuple("NonterminalKind::YulFunctionDefinition") + .finish(), + NonterminalKind::YulIfStatement => { + f.debug_tuple("NonterminalKind::YulIfStatement").finish() + } + NonterminalKind::YulLabel => { + f.debug_tuple("NonterminalKind::YulLabel").finish() + } + NonterminalKind::YulLeaveStatement => { + f.debug_tuple("NonterminalKind::YulLeaveStatement").finish() + } + NonterminalKind::YulLiteral => { + f.debug_tuple("NonterminalKind::YulLiteral").finish() + } + NonterminalKind::YulParameters => { + f.debug_tuple("NonterminalKind::YulParameters").finish() + } + NonterminalKind::YulParametersDeclaration => f + .debug_tuple("NonterminalKind::YulParametersDeclaration") + .finish(), + NonterminalKind::YulPath => { + f.debug_tuple("NonterminalKind::YulPath").finish() + } + NonterminalKind::YulPathComponent => { + f.debug_tuple("NonterminalKind::YulPathComponent").finish() + } + NonterminalKind::YulPaths => { + f.debug_tuple("NonterminalKind::YulPaths").finish() + } + NonterminalKind::YulReturnVariables => f + .debug_tuple("NonterminalKind::YulReturnVariables") + .finish(), + NonterminalKind::YulReturnsDeclaration => f + .debug_tuple("NonterminalKind::YulReturnsDeclaration") + .finish(), + NonterminalKind::YulStackAssignmentStatement => f + .debug_tuple("NonterminalKind::YulStackAssignmentStatement") + .finish(), + NonterminalKind::YulStatement => { + f.debug_tuple("NonterminalKind::YulStatement").finish() + } + NonterminalKind::YulStatements => { + f.debug_tuple("NonterminalKind::YulStatements").finish() + } + NonterminalKind::YulSwitchCase => { + f.debug_tuple("NonterminalKind::YulSwitchCase").finish() + } + NonterminalKind::YulSwitchCases => { + f.debug_tuple("NonterminalKind::YulSwitchCases").finish() + } + NonterminalKind::YulSwitchStatement => f + .debug_tuple("NonterminalKind::YulSwitchStatement") + .finish(), + NonterminalKind::YulValueCase => { + f.debug_tuple("NonterminalKind::YulValueCase").finish() + } + NonterminalKind::YulVariableAssignmentStatement => f + .debug_tuple("NonterminalKind::YulVariableAssignmentStatement") + .finish(), + NonterminalKind::YulVariableDeclarationStatement => f + .debug_tuple("NonterminalKind::YulVariableDeclarationStatement") + .finish(), + NonterminalKind::YulVariableDeclarationValue => f + .debug_tuple("NonterminalKind::YulVariableDeclarationValue") + .finish(), + } + } + } + + impl NonterminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> NonterminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => NonterminalKind::AbicoderPragma, + 1 => NonterminalKind::AdditiveExpression, + 2 => NonterminalKind::AddressType, + 3 => NonterminalKind::AndExpression, + 4 => NonterminalKind::ArgumentsDeclaration, + 5 => NonterminalKind::ArrayExpression, + 6 => NonterminalKind::ArrayTypeName, + 7 => NonterminalKind::ArrayValues, + 8 => NonterminalKind::AssemblyFlags, + 9 => NonterminalKind::AssemblyFlagsDeclaration, + 10 => NonterminalKind::AssemblyStatement, + 11 => NonterminalKind::AssignmentExpression, + 12 => NonterminalKind::BitwiseAndExpression, + 13 => NonterminalKind::BitwiseOrExpression, + 14 => NonterminalKind::BitwiseXorExpression, + 15 => NonterminalKind::Block, + 16 => NonterminalKind::BreakStatement, + 17 => NonterminalKind::CallOptions, + 18 => NonterminalKind::CallOptionsExpression, + 19 => NonterminalKind::CatchClause, + 20 => NonterminalKind::CatchClauseError, + 21 => NonterminalKind::CatchClauses, + 22 => NonterminalKind::ComparisonExpression, + 23 => NonterminalKind::ConditionalExpression, + 24 => NonterminalKind::ConstantDefinition, + 25 => NonterminalKind::ConstructorAttribute, + 26 => NonterminalKind::ConstructorAttributes, + 27 => NonterminalKind::ConstructorDefinition, + 28 => NonterminalKind::ContinueStatement, + 29 => NonterminalKind::ContractDefinition, + 30 => NonterminalKind::ContractMember, + 31 => NonterminalKind::ContractMembers, + 32 => NonterminalKind::DecimalNumberExpression, + 33 => NonterminalKind::DoWhileStatement, + 34 => NonterminalKind::ElementaryType, + 35 => NonterminalKind::ElseBranch, + 36 => NonterminalKind::EmitStatement, + 37 => NonterminalKind::EnumDefinition, + 38 => NonterminalKind::EnumMembers, + 39 => NonterminalKind::EqualityExpression, + 40 => NonterminalKind::ErrorDefinition, + 41 => NonterminalKind::ErrorParameter, + 42 => NonterminalKind::ErrorParameters, + 43 => NonterminalKind::ErrorParametersDeclaration, + 44 => NonterminalKind::EventDefinition, + 45 => NonterminalKind::EventParameter, + 46 => NonterminalKind::EventParameters, + 47 => NonterminalKind::EventParametersDeclaration, + 48 => NonterminalKind::ExperimentalFeature, + 49 => NonterminalKind::ExperimentalPragma, + 50 => NonterminalKind::ExponentiationExpression, + 51 => NonterminalKind::Expression, + 52 => NonterminalKind::ExpressionStatement, + 53 => NonterminalKind::FallbackFunctionAttribute, + 54 => NonterminalKind::FallbackFunctionAttributes, + 55 => NonterminalKind::FallbackFunctionDefinition, + 56 => NonterminalKind::ForStatement, + 57 => NonterminalKind::ForStatementCondition, + 58 => NonterminalKind::ForStatementInitialization, + 59 => NonterminalKind::FunctionAttribute, + 60 => NonterminalKind::FunctionAttributes, + 61 => NonterminalKind::FunctionBody, + 62 => NonterminalKind::FunctionCallExpression, + 63 => NonterminalKind::FunctionDefinition, + 64 => NonterminalKind::FunctionName, + 65 => NonterminalKind::FunctionType, + 66 => NonterminalKind::FunctionTypeAttribute, + 67 => NonterminalKind::FunctionTypeAttributes, + 68 => NonterminalKind::HexNumberExpression, + 69 => NonterminalKind::HexStringLiteral, + 70 => NonterminalKind::HexStringLiterals, + 71 => NonterminalKind::IdentifierPath, + 72 => NonterminalKind::IfStatement, + 73 => NonterminalKind::ImportAlias, + 74 => NonterminalKind::ImportClause, + 75 => NonterminalKind::ImportDeconstruction, + 76 => NonterminalKind::ImportDeconstructionSymbol, + 77 => NonterminalKind::ImportDeconstructionSymbols, + 78 => NonterminalKind::ImportDirective, + 79 => NonterminalKind::IndexAccessEnd, + 80 => NonterminalKind::IndexAccessExpression, + 81 => NonterminalKind::InheritanceSpecifier, + 82 => NonterminalKind::InheritanceType, + 83 => NonterminalKind::InheritanceTypes, + 84 => NonterminalKind::InterfaceDefinition, + 85 => NonterminalKind::InterfaceMembers, + 86 => NonterminalKind::LibraryDefinition, + 87 => NonterminalKind::LibraryMembers, + 88 => NonterminalKind::MappingKey, + 89 => NonterminalKind::MappingKeyType, + 90 => NonterminalKind::MappingType, + 91 => NonterminalKind::MappingValue, + 92 => NonterminalKind::MemberAccess, + 93 => NonterminalKind::MemberAccessExpression, + 94 => NonterminalKind::ModifierAttribute, + 95 => NonterminalKind::ModifierAttributes, + 96 => NonterminalKind::ModifierDefinition, + 97 => NonterminalKind::ModifierInvocation, + 98 => NonterminalKind::MultiplicativeExpression, + 99 => NonterminalKind::NamedArgument, + 100 => NonterminalKind::NamedArgumentGroup, + 101 => NonterminalKind::NamedArguments, + 102 => NonterminalKind::NamedArgumentsDeclaration, + 103 => NonterminalKind::NamedImport, + 104 => NonterminalKind::NewExpression, + 105 => NonterminalKind::NumberUnit, + 106 => NonterminalKind::OrExpression, + 107 => NonterminalKind::OverridePaths, + 108 => NonterminalKind::OverridePathsDeclaration, + 109 => NonterminalKind::OverrideSpecifier, + 110 => NonterminalKind::Parameter, + 111 => NonterminalKind::Parameters, + 112 => NonterminalKind::ParametersDeclaration, + 113 => NonterminalKind::PathImport, + 114 => NonterminalKind::PositionalArguments, + 115 => NonterminalKind::PositionalArgumentsDeclaration, + 116 => NonterminalKind::PostfixExpression, + 117 => NonterminalKind::Pragma, + 118 => NonterminalKind::PragmaDirective, + 119 => NonterminalKind::PrefixExpression, + 120 => NonterminalKind::ReceiveFunctionAttribute, + 121 => NonterminalKind::ReceiveFunctionAttributes, + 122 => NonterminalKind::ReceiveFunctionDefinition, + 123 => NonterminalKind::ReturnStatement, + 124 => NonterminalKind::ReturnsDeclaration, + 125 => NonterminalKind::RevertStatement, + 126 => NonterminalKind::ShiftExpression, + 127 => NonterminalKind::SourceUnit, + 128 => NonterminalKind::SourceUnitMember, + 129 => NonterminalKind::SourceUnitMembers, + 130 => NonterminalKind::StateVariableAttribute, + 131 => NonterminalKind::StateVariableAttributes, + 132 => NonterminalKind::StateVariableDefinition, + 133 => NonterminalKind::StateVariableDefinitionValue, + 134 => NonterminalKind::Statement, + 135 => NonterminalKind::Statements, + 136 => NonterminalKind::StorageLocation, + 137 => NonterminalKind::StringExpression, + 138 => NonterminalKind::StringLiteral, + 139 => NonterminalKind::StringLiterals, + 140 => NonterminalKind::StructDefinition, + 141 => NonterminalKind::StructMember, + 142 => NonterminalKind::StructMembers, + 143 => NonterminalKind::ThrowStatement, + 144 => NonterminalKind::TryStatement, + 145 => NonterminalKind::TupleDeconstructionElement, + 146 => NonterminalKind::TupleDeconstructionElements, + 147 => NonterminalKind::TupleDeconstructionStatement, + 148 => NonterminalKind::TupleExpression, + 149 => NonterminalKind::TupleMember, + 150 => NonterminalKind::TupleValue, + 151 => NonterminalKind::TupleValues, + 152 => NonterminalKind::TypeExpression, + 153 => NonterminalKind::TypeName, + 154 => NonterminalKind::TypedTupleMember, + 155 => NonterminalKind::UncheckedBlock, + 156 => NonterminalKind::UnicodeStringLiteral, + 157 => NonterminalKind::UnicodeStringLiterals, + 158 => NonterminalKind::UnnamedFunctionAttribute, + 159 => NonterminalKind::UnnamedFunctionAttributes, + 160 => NonterminalKind::UnnamedFunctionDefinition, + 161 => NonterminalKind::UntypedTupleMember, + 162 => NonterminalKind::UserDefinedValueTypeDefinition, + 163 => NonterminalKind::UsingAlias, + 164 => NonterminalKind::UsingClause, + 165 => NonterminalKind::UsingDeconstruction, + 166 => NonterminalKind::UsingDeconstructionSymbol, + 167 => NonterminalKind::UsingDeconstructionSymbols, + 168 => NonterminalKind::UsingDirective, + 169 => NonterminalKind::UsingOperator, + 170 => NonterminalKind::UsingTarget, + 171 => NonterminalKind::VariableDeclarationStatement, + 172 => NonterminalKind::VariableDeclarationType, + 173 => NonterminalKind::VariableDeclarationValue, + 174 => NonterminalKind::VersionComparator, + 175 => NonterminalKind::VersionExpression, + 176 => NonterminalKind::VersionExpressionSet, + 177 => NonterminalKind::VersionExpressionSets, + 178 => NonterminalKind::VersionPragma, + 179 => NonterminalKind::VersionRange, + 180 => NonterminalKind::VersionSpecifiers, + 181 => NonterminalKind::WhileStatement, + 182 => NonterminalKind::YulArguments, + 183 => NonterminalKind::YulAssignmentOperator, + 184 => NonterminalKind::YulBlock, + 185 => NonterminalKind::YulBreakStatement, + 186 => NonterminalKind::YulBuiltInFunction, + 187 => NonterminalKind::YulColonEqual, + 188 => NonterminalKind::YulContinueStatement, + 189 => NonterminalKind::YulDefaultCase, + 190 => NonterminalKind::YulExpression, + 191 => NonterminalKind::YulForStatement, + 192 => NonterminalKind::YulFunctionCallExpression, + 193 => NonterminalKind::YulFunctionDefinition, + 194 => NonterminalKind::YulIfStatement, + 195 => NonterminalKind::YulLabel, + 196 => NonterminalKind::YulLeaveStatement, + 197 => NonterminalKind::YulLiteral, + 198 => NonterminalKind::YulParameters, + 199 => NonterminalKind::YulParametersDeclaration, + 200 => NonterminalKind::YulPath, + 201 => NonterminalKind::YulPathComponent, + 202 => NonterminalKind::YulPaths, + 203 => NonterminalKind::YulReturnVariables, + 204 => NonterminalKind::YulReturnsDeclaration, + 205 => NonterminalKind::YulStackAssignmentStatement, + 206 => NonterminalKind::YulStatement, + 207 => NonterminalKind::YulStatements, + 208 => NonterminalKind::YulSwitchCase, + 209 => NonterminalKind::YulSwitchCases, + 210 => NonterminalKind::YulSwitchStatement, + 211 => NonterminalKind::YulValueCase, + 212 => NonterminalKind::YulVariableAssignmentStatement, + 213 => NonterminalKind::YulVariableDeclarationStatement, + 214 => NonterminalKind::YulVariableDeclarationValue, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum EdgeLabel { + /// Built-in: + Item, + Variant, + Separator, + Operand, + LeftOperand, + RightOperand, + LeadingTrivia, + TrailingTrivia, + /// Generated: + AbicoderKeyword, + AbstractKeyword, + AddressKeyword, + Alias, + AnonymousKeyword, + Arguments, + AsKeyword, + AssemblyKeyword, + Assignment, + Asterisk, + Attributes, + Block, + Body, + BreakKeyword, + CaseKeyword, + Cases, + CatchClauses, + CatchKeyword, + Clause, + CloseBrace, + CloseBracket, + CloseParen, + Colon, + Condition, + ConstantKeyword, + ConstructorKeyword, + ContinueKeyword, + ContractKeyword, + DefaultKeyword, + DoKeyword, + Elements, + ElseBranch, + ElseKeyword, + EmitKeyword, + End, + EnumKeyword, + Equal, + EqualGreaterThan, + Error, + ErrorKeyword, + Event, + EventKeyword, + ExperimentalKeyword, + Expression, + FallbackKeyword, + FalseExpression, + Feature, + Flags, + ForKeyword, + FromKeyword, + FunctionKeyword, + GlobalKeyword, + Identifier, + IfKeyword, + ImportKeyword, + Index, + IndexedKeyword, + Inheritance, + Initialization, + InterfaceKeyword, + IsKeyword, + Items, + Iterator, + KeyType, + Label, + LeaveKeyword, + LetKeyword, + LibraryKeyword, + Literal, + MappingKeyword, + Member, + Members, + MinusGreaterThan, + ModifierKeyword, + Name, + Names, + NewKeyword, + OpenBrace, + OpenBracket, + OpenParen, + Operator, + Options, + Overridden, + OverrideKeyword, + Parameters, + Path, + Paths, + PayableKeyword, + Period, + Pragma, + PragmaKeyword, + QuestionMark, + ReceiveKeyword, + ReturnKeyword, + Returns, + ReturnsKeyword, + RevertKeyword, + Semicolon, + Sets, + SolidityKeyword, + Start, + Statements, + StorageLocation, + StructKeyword, + SwitchKeyword, + Symbols, + Target, + ThrowKeyword, + TrueExpression, + TryKeyword, + TypeKeyword, + TypeName, + Types, + UncheckedKeyword, + Unit, + UsingKeyword, + Value, + ValueType, + VarKeyword, + VariableType, + Variables, + Version, + WhileKeyword, + } + impl ::core::fmt::Debug for EdgeLabel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + EdgeLabel::Item => f.debug_tuple("EdgeLabel::Item").finish(), + EdgeLabel::Variant => f.debug_tuple("EdgeLabel::Variant").finish(), + EdgeLabel::Separator => f.debug_tuple("EdgeLabel::Separator").finish(), + EdgeLabel::Operand => f.debug_tuple("EdgeLabel::Operand").finish(), + EdgeLabel::LeftOperand => { + f.debug_tuple("EdgeLabel::LeftOperand").finish() + } + EdgeLabel::RightOperand => { + f.debug_tuple("EdgeLabel::RightOperand").finish() + } + EdgeLabel::LeadingTrivia => { + f.debug_tuple("EdgeLabel::LeadingTrivia").finish() + } + EdgeLabel::TrailingTrivia => { + f.debug_tuple("EdgeLabel::TrailingTrivia").finish() + } + EdgeLabel::AbicoderKeyword => { + f.debug_tuple("EdgeLabel::AbicoderKeyword").finish() + } + EdgeLabel::AbstractKeyword => { + f.debug_tuple("EdgeLabel::AbstractKeyword").finish() + } + EdgeLabel::AddressKeyword => { + f.debug_tuple("EdgeLabel::AddressKeyword").finish() + } + EdgeLabel::Alias => f.debug_tuple("EdgeLabel::Alias").finish(), + EdgeLabel::AnonymousKeyword => { + f.debug_tuple("EdgeLabel::AnonymousKeyword").finish() + } + EdgeLabel::Arguments => f.debug_tuple("EdgeLabel::Arguments").finish(), + EdgeLabel::AsKeyword => f.debug_tuple("EdgeLabel::AsKeyword").finish(), + EdgeLabel::AssemblyKeyword => { + f.debug_tuple("EdgeLabel::AssemblyKeyword").finish() + } + EdgeLabel::Assignment => { + f.debug_tuple("EdgeLabel::Assignment").finish() + } + EdgeLabel::Asterisk => f.debug_tuple("EdgeLabel::Asterisk").finish(), + EdgeLabel::Attributes => { + f.debug_tuple("EdgeLabel::Attributes").finish() + } + EdgeLabel::Block => f.debug_tuple("EdgeLabel::Block").finish(), + EdgeLabel::Body => f.debug_tuple("EdgeLabel::Body").finish(), + EdgeLabel::BreakKeyword => { + f.debug_tuple("EdgeLabel::BreakKeyword").finish() + } + EdgeLabel::CaseKeyword => { + f.debug_tuple("EdgeLabel::CaseKeyword").finish() + } + EdgeLabel::Cases => f.debug_tuple("EdgeLabel::Cases").finish(), + EdgeLabel::CatchClauses => { + f.debug_tuple("EdgeLabel::CatchClauses").finish() + } + EdgeLabel::CatchKeyword => { + f.debug_tuple("EdgeLabel::CatchKeyword").finish() + } + EdgeLabel::Clause => f.debug_tuple("EdgeLabel::Clause").finish(), + EdgeLabel::CloseBrace => { + f.debug_tuple("EdgeLabel::CloseBrace").finish() + } + EdgeLabel::CloseBracket => { + f.debug_tuple("EdgeLabel::CloseBracket").finish() + } + EdgeLabel::CloseParen => { + f.debug_tuple("EdgeLabel::CloseParen").finish() + } + EdgeLabel::Colon => f.debug_tuple("EdgeLabel::Colon").finish(), + EdgeLabel::Condition => f.debug_tuple("EdgeLabel::Condition").finish(), + EdgeLabel::ConstantKeyword => { + f.debug_tuple("EdgeLabel::ConstantKeyword").finish() + } + EdgeLabel::ConstructorKeyword => { + f.debug_tuple("EdgeLabel::ConstructorKeyword").finish() + } + EdgeLabel::ContinueKeyword => { + f.debug_tuple("EdgeLabel::ContinueKeyword").finish() + } + EdgeLabel::ContractKeyword => { + f.debug_tuple("EdgeLabel::ContractKeyword").finish() + } + EdgeLabel::DefaultKeyword => { + f.debug_tuple("EdgeLabel::DefaultKeyword").finish() + } + EdgeLabel::DoKeyword => f.debug_tuple("EdgeLabel::DoKeyword").finish(), + EdgeLabel::Elements => f.debug_tuple("EdgeLabel::Elements").finish(), + EdgeLabel::ElseBranch => { + f.debug_tuple("EdgeLabel::ElseBranch").finish() + } + EdgeLabel::ElseKeyword => { + f.debug_tuple("EdgeLabel::ElseKeyword").finish() + } + EdgeLabel::EmitKeyword => { + f.debug_tuple("EdgeLabel::EmitKeyword").finish() + } + EdgeLabel::End => f.debug_tuple("EdgeLabel::End").finish(), + EdgeLabel::EnumKeyword => { + f.debug_tuple("EdgeLabel::EnumKeyword").finish() + } + EdgeLabel::Equal => f.debug_tuple("EdgeLabel::Equal").finish(), + EdgeLabel::EqualGreaterThan => { + f.debug_tuple("EdgeLabel::EqualGreaterThan").finish() + } + EdgeLabel::Error => f.debug_tuple("EdgeLabel::Error").finish(), + EdgeLabel::ErrorKeyword => { + f.debug_tuple("EdgeLabel::ErrorKeyword").finish() + } + EdgeLabel::Event => f.debug_tuple("EdgeLabel::Event").finish(), + EdgeLabel::EventKeyword => { + f.debug_tuple("EdgeLabel::EventKeyword").finish() + } + EdgeLabel::ExperimentalKeyword => { + f.debug_tuple("EdgeLabel::ExperimentalKeyword").finish() + } + EdgeLabel::Expression => { + f.debug_tuple("EdgeLabel::Expression").finish() + } + EdgeLabel::FallbackKeyword => { + f.debug_tuple("EdgeLabel::FallbackKeyword").finish() + } + EdgeLabel::FalseExpression => { + f.debug_tuple("EdgeLabel::FalseExpression").finish() + } + EdgeLabel::Feature => f.debug_tuple("EdgeLabel::Feature").finish(), + EdgeLabel::Flags => f.debug_tuple("EdgeLabel::Flags").finish(), + EdgeLabel::ForKeyword => { + f.debug_tuple("EdgeLabel::ForKeyword").finish() + } + EdgeLabel::FromKeyword => { + f.debug_tuple("EdgeLabel::FromKeyword").finish() + } + EdgeLabel::FunctionKeyword => { + f.debug_tuple("EdgeLabel::FunctionKeyword").finish() + } + EdgeLabel::GlobalKeyword => { + f.debug_tuple("EdgeLabel::GlobalKeyword").finish() + } + EdgeLabel::Identifier => { + f.debug_tuple("EdgeLabel::Identifier").finish() + } + EdgeLabel::IfKeyword => f.debug_tuple("EdgeLabel::IfKeyword").finish(), + EdgeLabel::ImportKeyword => { + f.debug_tuple("EdgeLabel::ImportKeyword").finish() + } + EdgeLabel::Index => f.debug_tuple("EdgeLabel::Index").finish(), + EdgeLabel::IndexedKeyword => { + f.debug_tuple("EdgeLabel::IndexedKeyword").finish() + } + EdgeLabel::Inheritance => { + f.debug_tuple("EdgeLabel::Inheritance").finish() + } + EdgeLabel::Initialization => { + f.debug_tuple("EdgeLabel::Initialization").finish() + } + EdgeLabel::InterfaceKeyword => { + f.debug_tuple("EdgeLabel::InterfaceKeyword").finish() + } + EdgeLabel::IsKeyword => f.debug_tuple("EdgeLabel::IsKeyword").finish(), + EdgeLabel::Items => f.debug_tuple("EdgeLabel::Items").finish(), + EdgeLabel::Iterator => f.debug_tuple("EdgeLabel::Iterator").finish(), + EdgeLabel::KeyType => f.debug_tuple("EdgeLabel::KeyType").finish(), + EdgeLabel::Label => f.debug_tuple("EdgeLabel::Label").finish(), + EdgeLabel::LeaveKeyword => { + f.debug_tuple("EdgeLabel::LeaveKeyword").finish() + } + EdgeLabel::LetKeyword => { + f.debug_tuple("EdgeLabel::LetKeyword").finish() + } + EdgeLabel::LibraryKeyword => { + f.debug_tuple("EdgeLabel::LibraryKeyword").finish() + } + EdgeLabel::Literal => f.debug_tuple("EdgeLabel::Literal").finish(), + EdgeLabel::MappingKeyword => { + f.debug_tuple("EdgeLabel::MappingKeyword").finish() + } + EdgeLabel::Member => f.debug_tuple("EdgeLabel::Member").finish(), + EdgeLabel::Members => f.debug_tuple("EdgeLabel::Members").finish(), + EdgeLabel::MinusGreaterThan => { + f.debug_tuple("EdgeLabel::MinusGreaterThan").finish() + } + EdgeLabel::ModifierKeyword => { + f.debug_tuple("EdgeLabel::ModifierKeyword").finish() + } + EdgeLabel::Name => f.debug_tuple("EdgeLabel::Name").finish(), + EdgeLabel::Names => f.debug_tuple("EdgeLabel::Names").finish(), + EdgeLabel::NewKeyword => { + f.debug_tuple("EdgeLabel::NewKeyword").finish() + } + EdgeLabel::OpenBrace => f.debug_tuple("EdgeLabel::OpenBrace").finish(), + EdgeLabel::OpenBracket => { + f.debug_tuple("EdgeLabel::OpenBracket").finish() + } + EdgeLabel::OpenParen => f.debug_tuple("EdgeLabel::OpenParen").finish(), + EdgeLabel::Operator => f.debug_tuple("EdgeLabel::Operator").finish(), + EdgeLabel::Options => f.debug_tuple("EdgeLabel::Options").finish(), + EdgeLabel::Overridden => { + f.debug_tuple("EdgeLabel::Overridden").finish() + } + EdgeLabel::OverrideKeyword => { + f.debug_tuple("EdgeLabel::OverrideKeyword").finish() + } + EdgeLabel::Parameters => { + f.debug_tuple("EdgeLabel::Parameters").finish() + } + EdgeLabel::Path => f.debug_tuple("EdgeLabel::Path").finish(), + EdgeLabel::Paths => f.debug_tuple("EdgeLabel::Paths").finish(), + EdgeLabel::PayableKeyword => { + f.debug_tuple("EdgeLabel::PayableKeyword").finish() + } + EdgeLabel::Period => f.debug_tuple("EdgeLabel::Period").finish(), + EdgeLabel::Pragma => f.debug_tuple("EdgeLabel::Pragma").finish(), + EdgeLabel::PragmaKeyword => { + f.debug_tuple("EdgeLabel::PragmaKeyword").finish() + } + EdgeLabel::QuestionMark => { + f.debug_tuple("EdgeLabel::QuestionMark").finish() + } + EdgeLabel::ReceiveKeyword => { + f.debug_tuple("EdgeLabel::ReceiveKeyword").finish() + } + EdgeLabel::ReturnKeyword => { + f.debug_tuple("EdgeLabel::ReturnKeyword").finish() + } + EdgeLabel::Returns => f.debug_tuple("EdgeLabel::Returns").finish(), + EdgeLabel::ReturnsKeyword => { + f.debug_tuple("EdgeLabel::ReturnsKeyword").finish() + } + EdgeLabel::RevertKeyword => { + f.debug_tuple("EdgeLabel::RevertKeyword").finish() + } + EdgeLabel::Semicolon => f.debug_tuple("EdgeLabel::Semicolon").finish(), + EdgeLabel::Sets => f.debug_tuple("EdgeLabel::Sets").finish(), + EdgeLabel::SolidityKeyword => { + f.debug_tuple("EdgeLabel::SolidityKeyword").finish() + } + EdgeLabel::Start => f.debug_tuple("EdgeLabel::Start").finish(), + EdgeLabel::Statements => { + f.debug_tuple("EdgeLabel::Statements").finish() + } + EdgeLabel::StorageLocation => { + f.debug_tuple("EdgeLabel::StorageLocation").finish() + } + EdgeLabel::StructKeyword => { + f.debug_tuple("EdgeLabel::StructKeyword").finish() + } + EdgeLabel::SwitchKeyword => { + f.debug_tuple("EdgeLabel::SwitchKeyword").finish() + } + EdgeLabel::Symbols => f.debug_tuple("EdgeLabel::Symbols").finish(), + EdgeLabel::Target => f.debug_tuple("EdgeLabel::Target").finish(), + EdgeLabel::ThrowKeyword => { + f.debug_tuple("EdgeLabel::ThrowKeyword").finish() + } + EdgeLabel::TrueExpression => { + f.debug_tuple("EdgeLabel::TrueExpression").finish() + } + EdgeLabel::TryKeyword => { + f.debug_tuple("EdgeLabel::TryKeyword").finish() + } + EdgeLabel::TypeKeyword => { + f.debug_tuple("EdgeLabel::TypeKeyword").finish() + } + EdgeLabel::TypeName => f.debug_tuple("EdgeLabel::TypeName").finish(), + EdgeLabel::Types => f.debug_tuple("EdgeLabel::Types").finish(), + EdgeLabel::UncheckedKeyword => { + f.debug_tuple("EdgeLabel::UncheckedKeyword").finish() + } + EdgeLabel::Unit => f.debug_tuple("EdgeLabel::Unit").finish(), + EdgeLabel::UsingKeyword => { + f.debug_tuple("EdgeLabel::UsingKeyword").finish() + } + EdgeLabel::Value => f.debug_tuple("EdgeLabel::Value").finish(), + EdgeLabel::ValueType => f.debug_tuple("EdgeLabel::ValueType").finish(), + EdgeLabel::VarKeyword => { + f.debug_tuple("EdgeLabel::VarKeyword").finish() + } + EdgeLabel::VariableType => { + f.debug_tuple("EdgeLabel::VariableType").finish() + } + EdgeLabel::Variables => f.debug_tuple("EdgeLabel::Variables").finish(), + EdgeLabel::Version => f.debug_tuple("EdgeLabel::Version").finish(), + EdgeLabel::WhileKeyword => { + f.debug_tuple("EdgeLabel::WhileKeyword").finish() + } + } + } + } + + impl EdgeLabel { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> EdgeLabel { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => EdgeLabel::Item, + 1 => EdgeLabel::Variant, + 2 => EdgeLabel::Separator, + 3 => EdgeLabel::Operand, + 4 => EdgeLabel::LeftOperand, + 5 => EdgeLabel::RightOperand, + 6 => EdgeLabel::LeadingTrivia, + 7 => EdgeLabel::TrailingTrivia, + 8 => EdgeLabel::AbicoderKeyword, + 9 => EdgeLabel::AbstractKeyword, + 10 => EdgeLabel::AddressKeyword, + 11 => EdgeLabel::Alias, + 12 => EdgeLabel::AnonymousKeyword, + 13 => EdgeLabel::Arguments, + 14 => EdgeLabel::AsKeyword, + 15 => EdgeLabel::AssemblyKeyword, + 16 => EdgeLabel::Assignment, + 17 => EdgeLabel::Asterisk, + 18 => EdgeLabel::Attributes, + 19 => EdgeLabel::Block, + 20 => EdgeLabel::Body, + 21 => EdgeLabel::BreakKeyword, + 22 => EdgeLabel::CaseKeyword, + 23 => EdgeLabel::Cases, + 24 => EdgeLabel::CatchClauses, + 25 => EdgeLabel::CatchKeyword, + 26 => EdgeLabel::Clause, + 27 => EdgeLabel::CloseBrace, + 28 => EdgeLabel::CloseBracket, + 29 => EdgeLabel::CloseParen, + 30 => EdgeLabel::Colon, + 31 => EdgeLabel::Condition, + 32 => EdgeLabel::ConstantKeyword, + 33 => EdgeLabel::ConstructorKeyword, + 34 => EdgeLabel::ContinueKeyword, + 35 => EdgeLabel::ContractKeyword, + 36 => EdgeLabel::DefaultKeyword, + 37 => EdgeLabel::DoKeyword, + 38 => EdgeLabel::Elements, + 39 => EdgeLabel::ElseBranch, + 40 => EdgeLabel::ElseKeyword, + 41 => EdgeLabel::EmitKeyword, + 42 => EdgeLabel::End, + 43 => EdgeLabel::EnumKeyword, + 44 => EdgeLabel::Equal, + 45 => EdgeLabel::EqualGreaterThan, + 46 => EdgeLabel::Error, + 47 => EdgeLabel::ErrorKeyword, + 48 => EdgeLabel::Event, + 49 => EdgeLabel::EventKeyword, + 50 => EdgeLabel::ExperimentalKeyword, + 51 => EdgeLabel::Expression, + 52 => EdgeLabel::FallbackKeyword, + 53 => EdgeLabel::FalseExpression, + 54 => EdgeLabel::Feature, + 55 => EdgeLabel::Flags, + 56 => EdgeLabel::ForKeyword, + 57 => EdgeLabel::FromKeyword, + 58 => EdgeLabel::FunctionKeyword, + 59 => EdgeLabel::GlobalKeyword, + 60 => EdgeLabel::Identifier, + 61 => EdgeLabel::IfKeyword, + 62 => EdgeLabel::ImportKeyword, + 63 => EdgeLabel::Index, + 64 => EdgeLabel::IndexedKeyword, + 65 => EdgeLabel::Inheritance, + 66 => EdgeLabel::Initialization, + 67 => EdgeLabel::InterfaceKeyword, + 68 => EdgeLabel::IsKeyword, + 69 => EdgeLabel::Items, + 70 => EdgeLabel::Iterator, + 71 => EdgeLabel::KeyType, + 72 => EdgeLabel::Label, + 73 => EdgeLabel::LeaveKeyword, + 74 => EdgeLabel::LetKeyword, + 75 => EdgeLabel::LibraryKeyword, + 76 => EdgeLabel::Literal, + 77 => EdgeLabel::MappingKeyword, + 78 => EdgeLabel::Member, + 79 => EdgeLabel::Members, + 80 => EdgeLabel::MinusGreaterThan, + 81 => EdgeLabel::ModifierKeyword, + 82 => EdgeLabel::Name, + 83 => EdgeLabel::Names, + 84 => EdgeLabel::NewKeyword, + 85 => EdgeLabel::OpenBrace, + 86 => EdgeLabel::OpenBracket, + 87 => EdgeLabel::OpenParen, + 88 => EdgeLabel::Operator, + 89 => EdgeLabel::Options, + 90 => EdgeLabel::Overridden, + 91 => EdgeLabel::OverrideKeyword, + 92 => EdgeLabel::Parameters, + 93 => EdgeLabel::Path, + 94 => EdgeLabel::Paths, + 95 => EdgeLabel::PayableKeyword, + 96 => EdgeLabel::Period, + 97 => EdgeLabel::Pragma, + 98 => EdgeLabel::PragmaKeyword, + 99 => EdgeLabel::QuestionMark, + 100 => EdgeLabel::ReceiveKeyword, + 101 => EdgeLabel::ReturnKeyword, + 102 => EdgeLabel::Returns, + 103 => EdgeLabel::ReturnsKeyword, + 104 => EdgeLabel::RevertKeyword, + 105 => EdgeLabel::Semicolon, + 106 => EdgeLabel::Sets, + 107 => EdgeLabel::SolidityKeyword, + 108 => EdgeLabel::Start, + 109 => EdgeLabel::Statements, + 110 => EdgeLabel::StorageLocation, + 111 => EdgeLabel::StructKeyword, + 112 => EdgeLabel::SwitchKeyword, + 113 => EdgeLabel::Symbols, + 114 => EdgeLabel::Target, + 115 => EdgeLabel::ThrowKeyword, + 116 => EdgeLabel::TrueExpression, + 117 => EdgeLabel::TryKeyword, + 118 => EdgeLabel::TypeKeyword, + 119 => EdgeLabel::TypeName, + 120 => EdgeLabel::Types, + 121 => EdgeLabel::UncheckedKeyword, + 122 => EdgeLabel::Unit, + 123 => EdgeLabel::UsingKeyword, + 124 => EdgeLabel::Value, + 125 => EdgeLabel::ValueType, + 126 => EdgeLabel::VarKeyword, + 127 => EdgeLabel::VariableType, + 128 => EdgeLabel::Variables, + 129 => EdgeLabel::Version, + 130 => EdgeLabel::WhileKeyword, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u16)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum TerminalKind { + /// Built-in: + Skipped, + /// Generated: + AbicoderKeyword, + AbstractKeyword, + AddressKeyword, + AfterKeyword, + AliasKeyword, + Ampersand, + AmpersandAmpersand, + AmpersandEqual, + AnonymousKeyword, + ApplyKeyword, + AsKeyword, + AssemblyKeyword, + Asterisk, + AsteriskAsterisk, + AsteriskEqual, + AutoKeyword, + Bang, + BangEqual, + Bar, + BarBar, + BarEqual, + BoolKeyword, + BreakKeyword, + ByteKeyword, + BytesKeyword, + CallDataKeyword, + Caret, + CaretEqual, + CaseKeyword, + CatchKeyword, + CloseBrace, + CloseBracket, + CloseParen, + Colon, + ColonEqual, + Comma, + ConstantKeyword, + ConstructorKeyword, + ContinueKeyword, + ContractKeyword, + CopyOfKeyword, + DaysKeyword, + DecimalLiteral, + DefaultKeyword, + DefineKeyword, + DeleteKeyword, + DoKeyword, + DoubleQuotedHexStringLiteral, + DoubleQuotedStringLiteral, + DoubleQuotedUnicodeStringLiteral, + DoubleQuotedVersionLiteral, + ElseKeyword, + EmitKeyword, + EndOfLine, + EnumKeyword, + Equal, + EqualEqual, + EqualGreaterThan, + ErrorKeyword, + EtherKeyword, + EventKeyword, + ExperimentalKeyword, + ExternalKeyword, + FallbackKeyword, + FalseKeyword, + FinalKeyword, + FinneyKeyword, + FixedKeyword, + ForKeyword, + FromKeyword, + FunctionKeyword, + GlobalKeyword, + GreaterThan, + GreaterThanEqual, + GreaterThanGreaterThan, + GreaterThanGreaterThanEqual, + GreaterThanGreaterThanGreaterThan, + GreaterThanGreaterThanGreaterThanEqual, + GweiKeyword, + HexKeyword, + HexLiteral, + HoursKeyword, + Identifier, + IfKeyword, + ImmutableKeyword, + ImplementsKeyword, + ImportKeyword, + InKeyword, + IndexedKeyword, + InlineKeyword, + IntKeyword, + InterfaceKeyword, + InternalKeyword, + IsKeyword, + LessThan, + LessThanEqual, + LessThanLessThan, + LessThanLessThanEqual, + LetKeyword, + LibraryKeyword, + MacroKeyword, + MappingKeyword, + MatchKeyword, + MemoryKeyword, + Minus, + MinusEqual, + MinusGreaterThan, + MinusMinus, + MinutesKeyword, + ModifierKeyword, + MultiLineComment, + MultiLineNatSpecComment, + MutableKeyword, + NewKeyword, + NullKeyword, + OfKeyword, + OpenBrace, + OpenBracket, + OpenParen, + OverrideKeyword, + PartialKeyword, + PayableKeyword, + Percent, + PercentEqual, + Period, + Plus, + PlusEqual, + PlusPlus, + PragmaKeyword, + PrivateKeyword, + PromiseKeyword, + PublicKeyword, + PureKeyword, + QuestionMark, + ReceiveKeyword, + ReferenceKeyword, + RelocatableKeyword, + ReturnKeyword, + ReturnsKeyword, + RevertKeyword, + SealedKeyword, + SecondsKeyword, + Semicolon, + SingleLineComment, + SingleLineNatSpecComment, + SingleQuotedHexStringLiteral, + SingleQuotedStringLiteral, + SingleQuotedUnicodeStringLiteral, + SingleQuotedVersionLiteral, + SizeOfKeyword, + Slash, + SlashEqual, + SolidityKeyword, + StaticKeyword, + StorageKeyword, + StringKeyword, + StructKeyword, + SupportsKeyword, + SwitchKeyword, + SzaboKeyword, + ThrowKeyword, + Tilde, + TrueKeyword, + TryKeyword, + TypeDefKeyword, + TypeKeyword, + TypeOfKeyword, + UfixedKeyword, + UintKeyword, + UncheckedKeyword, + UsingKeyword, + VarKeyword, + VersionSpecifier, + ViewKeyword, + VirtualKeyword, + WeeksKeyword, + WeiKeyword, + WhileKeyword, + Whitespace, + YearsKeyword, + YulAbstractKeyword, + YulAddKeyword, + YulAddModKeyword, + YulAddressKeyword, + YulAfterKeyword, + YulAliasKeyword, + YulAndKeyword, + YulAnonymousKeyword, + YulApplyKeyword, + YulAsKeyword, + YulAssemblyKeyword, + YulAutoKeyword, + YulBalanceKeyword, + YulBaseFeeKeyword, + YulBlobBaseFeeKeyword, + YulBlobHashKeyword, + YulBlockHashKeyword, + YulBoolKeyword, + YulBreakKeyword, + YulByteKeyword, + YulBytesKeyword, + YulCallCodeKeyword, + YulCallDataCopyKeyword, + YulCallDataKeyword, + YulCallDataLoadKeyword, + YulCallDataSizeKeyword, + YulCallKeyword, + YulCallValueKeyword, + YulCallerKeyword, + YulCaseKeyword, + YulCatchKeyword, + YulChainIdKeyword, + YulCoinBaseKeyword, + YulConstantKeyword, + YulConstructorKeyword, + YulContinueKeyword, + YulContractKeyword, + YulCopyOfKeyword, + YulCreate2Keyword, + YulCreateKeyword, + YulDaysKeyword, + YulDecimalLiteral, + YulDefaultKeyword, + YulDefineKeyword, + YulDelegateCallKeyword, + YulDeleteKeyword, + YulDifficultyKeyword, + YulDivKeyword, + YulDoKeyword, + YulElseKeyword, + YulEmitKeyword, + YulEnumKeyword, + YulEqKeyword, + YulEtherKeyword, + YulEventKeyword, + YulExpKeyword, + YulExtCodeCopyKeyword, + YulExtCodeHashKeyword, + YulExtCodeSizeKeyword, + YulExternalKeyword, + YulFallbackKeyword, + YulFalseKeyword, + YulFinalKeyword, + YulFinneyKeyword, + YulFixedKeyword, + YulForKeyword, + YulFunctionKeyword, + YulGasKeyword, + YulGasLimitKeyword, + YulGasPriceKeyword, + YulGtKeyword, + YulGweiKeyword, + YulHexKeyword, + YulHexLiteral, + YulHoursKeyword, + YulIdentifier, + YulIfKeyword, + YulImmutableKeyword, + YulImplementsKeyword, + YulImportKeyword, + YulInKeyword, + YulIndexedKeyword, + YulInlineKeyword, + YulIntKeyword, + YulInterfaceKeyword, + YulInternalKeyword, + YulInvalidKeyword, + YulIsKeyword, + YulIsZeroKeyword, + YulKeccak256Keyword, + YulLeaveKeyword, + YulLetKeyword, + YulLibraryKeyword, + YulLog0Keyword, + YulLog1Keyword, + YulLog2Keyword, + YulLog3Keyword, + YulLog4Keyword, + YulLtKeyword, + YulMcopyKeyword, + YulMloadKeyword, + YulMsizeKeyword, + YulMstore8Keyword, + YulMstoreKeyword, + YulMacroKeyword, + YulMappingKeyword, + YulMatchKeyword, + YulMemoryKeyword, + YulMinutesKeyword, + YulModKeyword, + YulModifierKeyword, + YulMulKeyword, + YulMulModKeyword, + YulMutableKeyword, + YulNewKeyword, + YulNotKeyword, + YulNullKeyword, + YulNumberKeyword, + YulOfKeyword, + YulOrKeyword, + YulOriginKeyword, + YulOverrideKeyword, + YulPartialKeyword, + YulPayableKeyword, + YulPopKeyword, + YulPragmaKeyword, + YulPrevRandaoKeyword, + YulPrivateKeyword, + YulPromiseKeyword, + YulPublicKeyword, + YulPureKeyword, + YulReceiveKeyword, + YulReferenceKeyword, + YulRelocatableKeyword, + YulReturnDataCopyKeyword, + YulReturnDataSizeKeyword, + YulReturnKeyword, + YulReturnsKeyword, + YulRevertKeyword, + YulSdivKeyword, + YulSloadKeyword, + YulSmodKeyword, + YulSstoreKeyword, + YulSarKeyword, + YulSealedKeyword, + YulSecondsKeyword, + YulSelfBalanceKeyword, + YulSelfDestructKeyword, + YulSgtKeyword, + YulSha3Keyword, + YulShlKeyword, + YulShrKeyword, + YulSignExtendKeyword, + YulSizeOfKeyword, + YulSltKeyword, + YulStaticCallKeyword, + YulStaticKeyword, + YulStopKeyword, + YulStorageKeyword, + YulStringKeyword, + YulStructKeyword, + YulSubKeyword, + YulSuicideKeyword, + YulSupportsKeyword, + YulSwitchKeyword, + YulSzaboKeyword, + YulTloadKeyword, + YulTstoreKeyword, + YulThrowKeyword, + YulTimestampKeyword, + YulTrueKeyword, + YulTryKeyword, + YulTypeDefKeyword, + YulTypeKeyword, + YulTypeOfKeyword, + YulUfixedKeyword, + YulUintKeyword, + YulUncheckedKeyword, + YulUsingKeyword, + YulVarKeyword, + YulViewKeyword, + YulVirtualKeyword, + YulWeeksKeyword, + YulWeiKeyword, + YulWhileKeyword, + YulXorKeyword, + YulYearsKeyword, + } + impl ::core::fmt::Debug for TerminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + TerminalKind::Skipped => { + f.debug_tuple("TerminalKind::Skipped").finish() + } + TerminalKind::AbicoderKeyword => { + f.debug_tuple("TerminalKind::AbicoderKeyword").finish() + } + TerminalKind::AbstractKeyword => { + f.debug_tuple("TerminalKind::AbstractKeyword").finish() + } + TerminalKind::AddressKeyword => { + f.debug_tuple("TerminalKind::AddressKeyword").finish() + } + TerminalKind::AfterKeyword => { + f.debug_tuple("TerminalKind::AfterKeyword").finish() + } + TerminalKind::AliasKeyword => { + f.debug_tuple("TerminalKind::AliasKeyword").finish() + } + TerminalKind::Ampersand => { + f.debug_tuple("TerminalKind::Ampersand").finish() + } + TerminalKind::AmpersandAmpersand => { + f.debug_tuple("TerminalKind::AmpersandAmpersand").finish() + } + TerminalKind::AmpersandEqual => { + f.debug_tuple("TerminalKind::AmpersandEqual").finish() + } + TerminalKind::AnonymousKeyword => { + f.debug_tuple("TerminalKind::AnonymousKeyword").finish() + } + TerminalKind::ApplyKeyword => { + f.debug_tuple("TerminalKind::ApplyKeyword").finish() + } + TerminalKind::AsKeyword => { + f.debug_tuple("TerminalKind::AsKeyword").finish() + } + TerminalKind::AssemblyKeyword => { + f.debug_tuple("TerminalKind::AssemblyKeyword").finish() + } + TerminalKind::Asterisk => { + f.debug_tuple("TerminalKind::Asterisk").finish() + } + TerminalKind::AsteriskAsterisk => { + f.debug_tuple("TerminalKind::AsteriskAsterisk").finish() + } + TerminalKind::AsteriskEqual => { + f.debug_tuple("TerminalKind::AsteriskEqual").finish() + } + TerminalKind::AutoKeyword => { + f.debug_tuple("TerminalKind::AutoKeyword").finish() + } + TerminalKind::Bang => f.debug_tuple("TerminalKind::Bang").finish(), + TerminalKind::BangEqual => { + f.debug_tuple("TerminalKind::BangEqual").finish() + } + TerminalKind::Bar => f.debug_tuple("TerminalKind::Bar").finish(), + TerminalKind::BarBar => f.debug_tuple("TerminalKind::BarBar").finish(), + TerminalKind::BarEqual => { + f.debug_tuple("TerminalKind::BarEqual").finish() + } + TerminalKind::BoolKeyword => { + f.debug_tuple("TerminalKind::BoolKeyword").finish() + } + TerminalKind::BreakKeyword => { + f.debug_tuple("TerminalKind::BreakKeyword").finish() + } + TerminalKind::ByteKeyword => { + f.debug_tuple("TerminalKind::ByteKeyword").finish() + } + TerminalKind::BytesKeyword => { + f.debug_tuple("TerminalKind::BytesKeyword").finish() + } + TerminalKind::CallDataKeyword => { + f.debug_tuple("TerminalKind::CallDataKeyword").finish() + } + TerminalKind::Caret => f.debug_tuple("TerminalKind::Caret").finish(), + TerminalKind::CaretEqual => { + f.debug_tuple("TerminalKind::CaretEqual").finish() + } + TerminalKind::CaseKeyword => { + f.debug_tuple("TerminalKind::CaseKeyword").finish() + } + TerminalKind::CatchKeyword => { + f.debug_tuple("TerminalKind::CatchKeyword").finish() + } + TerminalKind::CloseBrace => { + f.debug_tuple("TerminalKind::CloseBrace").finish() + } + TerminalKind::CloseBracket => { + f.debug_tuple("TerminalKind::CloseBracket").finish() + } + TerminalKind::CloseParen => { + f.debug_tuple("TerminalKind::CloseParen").finish() + } + TerminalKind::Colon => f.debug_tuple("TerminalKind::Colon").finish(), + TerminalKind::ColonEqual => { + f.debug_tuple("TerminalKind::ColonEqual").finish() + } + TerminalKind::Comma => f.debug_tuple("TerminalKind::Comma").finish(), + TerminalKind::ConstantKeyword => { + f.debug_tuple("TerminalKind::ConstantKeyword").finish() + } + TerminalKind::ConstructorKeyword => { + f.debug_tuple("TerminalKind::ConstructorKeyword").finish() + } + TerminalKind::ContinueKeyword => { + f.debug_tuple("TerminalKind::ContinueKeyword").finish() + } + TerminalKind::ContractKeyword => { + f.debug_tuple("TerminalKind::ContractKeyword").finish() + } + TerminalKind::CopyOfKeyword => { + f.debug_tuple("TerminalKind::CopyOfKeyword").finish() + } + TerminalKind::DaysKeyword => { + f.debug_tuple("TerminalKind::DaysKeyword").finish() + } + TerminalKind::DecimalLiteral => { + f.debug_tuple("TerminalKind::DecimalLiteral").finish() + } + TerminalKind::DefaultKeyword => { + f.debug_tuple("TerminalKind::DefaultKeyword").finish() + } + TerminalKind::DefineKeyword => { + f.debug_tuple("TerminalKind::DefineKeyword").finish() + } + TerminalKind::DeleteKeyword => { + f.debug_tuple("TerminalKind::DeleteKeyword").finish() + } + TerminalKind::DoKeyword => { + f.debug_tuple("TerminalKind::DoKeyword").finish() + } + TerminalKind::DoubleQuotedHexStringLiteral => f + .debug_tuple("TerminalKind::DoubleQuotedHexStringLiteral") + .finish(), + TerminalKind::DoubleQuotedStringLiteral => f + .debug_tuple("TerminalKind::DoubleQuotedStringLiteral") + .finish(), + TerminalKind::DoubleQuotedUnicodeStringLiteral => f + .debug_tuple("TerminalKind::DoubleQuotedUnicodeStringLiteral") + .finish(), + TerminalKind::DoubleQuotedVersionLiteral => f + .debug_tuple("TerminalKind::DoubleQuotedVersionLiteral") + .finish(), + TerminalKind::ElseKeyword => { + f.debug_tuple("TerminalKind::ElseKeyword").finish() + } + TerminalKind::EmitKeyword => { + f.debug_tuple("TerminalKind::EmitKeyword").finish() + } + TerminalKind::EndOfLine => { + f.debug_tuple("TerminalKind::EndOfLine").finish() + } + TerminalKind::EnumKeyword => { + f.debug_tuple("TerminalKind::EnumKeyword").finish() + } + TerminalKind::Equal => f.debug_tuple("TerminalKind::Equal").finish(), + TerminalKind::EqualEqual => { + f.debug_tuple("TerminalKind::EqualEqual").finish() + } + TerminalKind::EqualGreaterThan => { + f.debug_tuple("TerminalKind::EqualGreaterThan").finish() + } + TerminalKind::ErrorKeyword => { + f.debug_tuple("TerminalKind::ErrorKeyword").finish() + } + TerminalKind::EtherKeyword => { + f.debug_tuple("TerminalKind::EtherKeyword").finish() + } + TerminalKind::EventKeyword => { + f.debug_tuple("TerminalKind::EventKeyword").finish() + } + TerminalKind::ExperimentalKeyword => { + f.debug_tuple("TerminalKind::ExperimentalKeyword").finish() + } + TerminalKind::ExternalKeyword => { + f.debug_tuple("TerminalKind::ExternalKeyword").finish() + } + TerminalKind::FallbackKeyword => { + f.debug_tuple("TerminalKind::FallbackKeyword").finish() + } + TerminalKind::FalseKeyword => { + f.debug_tuple("TerminalKind::FalseKeyword").finish() + } + TerminalKind::FinalKeyword => { + f.debug_tuple("TerminalKind::FinalKeyword").finish() + } + TerminalKind::FinneyKeyword => { + f.debug_tuple("TerminalKind::FinneyKeyword").finish() + } + TerminalKind::FixedKeyword => { + f.debug_tuple("TerminalKind::FixedKeyword").finish() + } + TerminalKind::ForKeyword => { + f.debug_tuple("TerminalKind::ForKeyword").finish() + } + TerminalKind::FromKeyword => { + f.debug_tuple("TerminalKind::FromKeyword").finish() + } + TerminalKind::FunctionKeyword => { + f.debug_tuple("TerminalKind::FunctionKeyword").finish() + } + TerminalKind::GlobalKeyword => { + f.debug_tuple("TerminalKind::GlobalKeyword").finish() + } + TerminalKind::GreaterThan => { + f.debug_tuple("TerminalKind::GreaterThan").finish() + } + TerminalKind::GreaterThanEqual => { + f.debug_tuple("TerminalKind::GreaterThanEqual").finish() + } + TerminalKind::GreaterThanGreaterThan => f + .debug_tuple("TerminalKind::GreaterThanGreaterThan") + .finish(), + TerminalKind::GreaterThanGreaterThanEqual => f + .debug_tuple("TerminalKind::GreaterThanGreaterThanEqual") + .finish(), + TerminalKind::GreaterThanGreaterThanGreaterThan => f + .debug_tuple("TerminalKind::GreaterThanGreaterThanGreaterThan") + .finish(), + TerminalKind::GreaterThanGreaterThanGreaterThanEqual => f + .debug_tuple("TerminalKind::GreaterThanGreaterThanGreaterThanEqual") + .finish(), + TerminalKind::GweiKeyword => { + f.debug_tuple("TerminalKind::GweiKeyword").finish() + } + TerminalKind::HexKeyword => { + f.debug_tuple("TerminalKind::HexKeyword").finish() + } + TerminalKind::HexLiteral => { + f.debug_tuple("TerminalKind::HexLiteral").finish() + } + TerminalKind::HoursKeyword => { + f.debug_tuple("TerminalKind::HoursKeyword").finish() + } + TerminalKind::Identifier => { + f.debug_tuple("TerminalKind::Identifier").finish() + } + TerminalKind::IfKeyword => { + f.debug_tuple("TerminalKind::IfKeyword").finish() + } + TerminalKind::ImmutableKeyword => { + f.debug_tuple("TerminalKind::ImmutableKeyword").finish() + } + TerminalKind::ImplementsKeyword => { + f.debug_tuple("TerminalKind::ImplementsKeyword").finish() + } + TerminalKind::ImportKeyword => { + f.debug_tuple("TerminalKind::ImportKeyword").finish() + } + TerminalKind::InKeyword => { + f.debug_tuple("TerminalKind::InKeyword").finish() + } + TerminalKind::IndexedKeyword => { + f.debug_tuple("TerminalKind::IndexedKeyword").finish() + } + TerminalKind::InlineKeyword => { + f.debug_tuple("TerminalKind::InlineKeyword").finish() + } + TerminalKind::IntKeyword => { + f.debug_tuple("TerminalKind::IntKeyword").finish() + } + TerminalKind::InterfaceKeyword => { + f.debug_tuple("TerminalKind::InterfaceKeyword").finish() + } + TerminalKind::InternalKeyword => { + f.debug_tuple("TerminalKind::InternalKeyword").finish() + } + TerminalKind::IsKeyword => { + f.debug_tuple("TerminalKind::IsKeyword").finish() + } + TerminalKind::LessThan => { + f.debug_tuple("TerminalKind::LessThan").finish() + } + TerminalKind::LessThanEqual => { + f.debug_tuple("TerminalKind::LessThanEqual").finish() + } + TerminalKind::LessThanLessThan => { + f.debug_tuple("TerminalKind::LessThanLessThan").finish() + } + TerminalKind::LessThanLessThanEqual => f + .debug_tuple("TerminalKind::LessThanLessThanEqual") + .finish(), + TerminalKind::LetKeyword => { + f.debug_tuple("TerminalKind::LetKeyword").finish() + } + TerminalKind::LibraryKeyword => { + f.debug_tuple("TerminalKind::LibraryKeyword").finish() + } + TerminalKind::MacroKeyword => { + f.debug_tuple("TerminalKind::MacroKeyword").finish() + } + TerminalKind::MappingKeyword => { + f.debug_tuple("TerminalKind::MappingKeyword").finish() + } + TerminalKind::MatchKeyword => { + f.debug_tuple("TerminalKind::MatchKeyword").finish() + } + TerminalKind::MemoryKeyword => { + f.debug_tuple("TerminalKind::MemoryKeyword").finish() + } + TerminalKind::Minus => f.debug_tuple("TerminalKind::Minus").finish(), + TerminalKind::MinusEqual => { + f.debug_tuple("TerminalKind::MinusEqual").finish() + } + TerminalKind::MinusGreaterThan => { + f.debug_tuple("TerminalKind::MinusGreaterThan").finish() + } + TerminalKind::MinusMinus => { + f.debug_tuple("TerminalKind::MinusMinus").finish() + } + TerminalKind::MinutesKeyword => { + f.debug_tuple("TerminalKind::MinutesKeyword").finish() + } + TerminalKind::ModifierKeyword => { + f.debug_tuple("TerminalKind::ModifierKeyword").finish() + } + TerminalKind::MultiLineComment => { + f.debug_tuple("TerminalKind::MultiLineComment").finish() + } + TerminalKind::MultiLineNatSpecComment => f + .debug_tuple("TerminalKind::MultiLineNatSpecComment") + .finish(), + TerminalKind::MutableKeyword => { + f.debug_tuple("TerminalKind::MutableKeyword").finish() + } + TerminalKind::NewKeyword => { + f.debug_tuple("TerminalKind::NewKeyword").finish() + } + TerminalKind::NullKeyword => { + f.debug_tuple("TerminalKind::NullKeyword").finish() + } + TerminalKind::OfKeyword => { + f.debug_tuple("TerminalKind::OfKeyword").finish() + } + TerminalKind::OpenBrace => { + f.debug_tuple("TerminalKind::OpenBrace").finish() + } + TerminalKind::OpenBracket => { + f.debug_tuple("TerminalKind::OpenBracket").finish() + } + TerminalKind::OpenParen => { + f.debug_tuple("TerminalKind::OpenParen").finish() + } + TerminalKind::OverrideKeyword => { + f.debug_tuple("TerminalKind::OverrideKeyword").finish() + } + TerminalKind::PartialKeyword => { + f.debug_tuple("TerminalKind::PartialKeyword").finish() + } + TerminalKind::PayableKeyword => { + f.debug_tuple("TerminalKind::PayableKeyword").finish() + } + TerminalKind::Percent => { + f.debug_tuple("TerminalKind::Percent").finish() + } + TerminalKind::PercentEqual => { + f.debug_tuple("TerminalKind::PercentEqual").finish() + } + TerminalKind::Period => f.debug_tuple("TerminalKind::Period").finish(), + TerminalKind::Plus => f.debug_tuple("TerminalKind::Plus").finish(), + TerminalKind::PlusEqual => { + f.debug_tuple("TerminalKind::PlusEqual").finish() + } + TerminalKind::PlusPlus => { + f.debug_tuple("TerminalKind::PlusPlus").finish() + } + TerminalKind::PragmaKeyword => { + f.debug_tuple("TerminalKind::PragmaKeyword").finish() + } + TerminalKind::PrivateKeyword => { + f.debug_tuple("TerminalKind::PrivateKeyword").finish() + } + TerminalKind::PromiseKeyword => { + f.debug_tuple("TerminalKind::PromiseKeyword").finish() + } + TerminalKind::PublicKeyword => { + f.debug_tuple("TerminalKind::PublicKeyword").finish() + } + TerminalKind::PureKeyword => { + f.debug_tuple("TerminalKind::PureKeyword").finish() + } + TerminalKind::QuestionMark => { + f.debug_tuple("TerminalKind::QuestionMark").finish() + } + TerminalKind::ReceiveKeyword => { + f.debug_tuple("TerminalKind::ReceiveKeyword").finish() + } + TerminalKind::ReferenceKeyword => { + f.debug_tuple("TerminalKind::ReferenceKeyword").finish() + } + TerminalKind::RelocatableKeyword => { + f.debug_tuple("TerminalKind::RelocatableKeyword").finish() + } + TerminalKind::ReturnKeyword => { + f.debug_tuple("TerminalKind::ReturnKeyword").finish() + } + TerminalKind::ReturnsKeyword => { + f.debug_tuple("TerminalKind::ReturnsKeyword").finish() + } + TerminalKind::RevertKeyword => { + f.debug_tuple("TerminalKind::RevertKeyword").finish() + } + TerminalKind::SealedKeyword => { + f.debug_tuple("TerminalKind::SealedKeyword").finish() + } + TerminalKind::SecondsKeyword => { + f.debug_tuple("TerminalKind::SecondsKeyword").finish() + } + TerminalKind::Semicolon => { + f.debug_tuple("TerminalKind::Semicolon").finish() + } + TerminalKind::SingleLineComment => { + f.debug_tuple("TerminalKind::SingleLineComment").finish() + } + TerminalKind::SingleLineNatSpecComment => f + .debug_tuple("TerminalKind::SingleLineNatSpecComment") + .finish(), + TerminalKind::SingleQuotedHexStringLiteral => f + .debug_tuple("TerminalKind::SingleQuotedHexStringLiteral") + .finish(), + TerminalKind::SingleQuotedStringLiteral => f + .debug_tuple("TerminalKind::SingleQuotedStringLiteral") + .finish(), + TerminalKind::SingleQuotedUnicodeStringLiteral => f + .debug_tuple("TerminalKind::SingleQuotedUnicodeStringLiteral") + .finish(), + TerminalKind::SingleQuotedVersionLiteral => f + .debug_tuple("TerminalKind::SingleQuotedVersionLiteral") + .finish(), + TerminalKind::SizeOfKeyword => { + f.debug_tuple("TerminalKind::SizeOfKeyword").finish() + } + TerminalKind::Slash => f.debug_tuple("TerminalKind::Slash").finish(), + TerminalKind::SlashEqual => { + f.debug_tuple("TerminalKind::SlashEqual").finish() + } + TerminalKind::SolidityKeyword => { + f.debug_tuple("TerminalKind::SolidityKeyword").finish() + } + TerminalKind::StaticKeyword => { + f.debug_tuple("TerminalKind::StaticKeyword").finish() + } + TerminalKind::StorageKeyword => { + f.debug_tuple("TerminalKind::StorageKeyword").finish() + } + TerminalKind::StringKeyword => { + f.debug_tuple("TerminalKind::StringKeyword").finish() + } + TerminalKind::StructKeyword => { + f.debug_tuple("TerminalKind::StructKeyword").finish() + } + TerminalKind::SupportsKeyword => { + f.debug_tuple("TerminalKind::SupportsKeyword").finish() + } + TerminalKind::SwitchKeyword => { + f.debug_tuple("TerminalKind::SwitchKeyword").finish() + } + TerminalKind::SzaboKeyword => { + f.debug_tuple("TerminalKind::SzaboKeyword").finish() + } + TerminalKind::ThrowKeyword => { + f.debug_tuple("TerminalKind::ThrowKeyword").finish() + } + TerminalKind::Tilde => f.debug_tuple("TerminalKind::Tilde").finish(), + TerminalKind::TrueKeyword => { + f.debug_tuple("TerminalKind::TrueKeyword").finish() + } + TerminalKind::TryKeyword => { + f.debug_tuple("TerminalKind::TryKeyword").finish() + } + TerminalKind::TypeDefKeyword => { + f.debug_tuple("TerminalKind::TypeDefKeyword").finish() + } + TerminalKind::TypeKeyword => { + f.debug_tuple("TerminalKind::TypeKeyword").finish() + } + TerminalKind::TypeOfKeyword => { + f.debug_tuple("TerminalKind::TypeOfKeyword").finish() + } + TerminalKind::UfixedKeyword => { + f.debug_tuple("TerminalKind::UfixedKeyword").finish() + } + TerminalKind::UintKeyword => { + f.debug_tuple("TerminalKind::UintKeyword").finish() + } + TerminalKind::UncheckedKeyword => { + f.debug_tuple("TerminalKind::UncheckedKeyword").finish() + } + TerminalKind::UsingKeyword => { + f.debug_tuple("TerminalKind::UsingKeyword").finish() + } + TerminalKind::VarKeyword => { + f.debug_tuple("TerminalKind::VarKeyword").finish() + } + TerminalKind::VersionSpecifier => { + f.debug_tuple("TerminalKind::VersionSpecifier").finish() + } + TerminalKind::ViewKeyword => { + f.debug_tuple("TerminalKind::ViewKeyword").finish() + } + TerminalKind::VirtualKeyword => { + f.debug_tuple("TerminalKind::VirtualKeyword").finish() + } + TerminalKind::WeeksKeyword => { + f.debug_tuple("TerminalKind::WeeksKeyword").finish() + } + TerminalKind::WeiKeyword => { + f.debug_tuple("TerminalKind::WeiKeyword").finish() + } + TerminalKind::WhileKeyword => { + f.debug_tuple("TerminalKind::WhileKeyword").finish() + } + TerminalKind::Whitespace => { + f.debug_tuple("TerminalKind::Whitespace").finish() + } + TerminalKind::YearsKeyword => { + f.debug_tuple("TerminalKind::YearsKeyword").finish() + } + TerminalKind::YulAbstractKeyword => { + f.debug_tuple("TerminalKind::YulAbstractKeyword").finish() + } + TerminalKind::YulAddKeyword => { + f.debug_tuple("TerminalKind::YulAddKeyword").finish() + } + TerminalKind::YulAddModKeyword => { + f.debug_tuple("TerminalKind::YulAddModKeyword").finish() + } + TerminalKind::YulAddressKeyword => { + f.debug_tuple("TerminalKind::YulAddressKeyword").finish() + } + TerminalKind::YulAfterKeyword => { + f.debug_tuple("TerminalKind::YulAfterKeyword").finish() + } + TerminalKind::YulAliasKeyword => { + f.debug_tuple("TerminalKind::YulAliasKeyword").finish() + } + TerminalKind::YulAndKeyword => { + f.debug_tuple("TerminalKind::YulAndKeyword").finish() + } + TerminalKind::YulAnonymousKeyword => { + f.debug_tuple("TerminalKind::YulAnonymousKeyword").finish() + } + TerminalKind::YulApplyKeyword => { + f.debug_tuple("TerminalKind::YulApplyKeyword").finish() + } + TerminalKind::YulAsKeyword => { + f.debug_tuple("TerminalKind::YulAsKeyword").finish() + } + TerminalKind::YulAssemblyKeyword => { + f.debug_tuple("TerminalKind::YulAssemblyKeyword").finish() + } + TerminalKind::YulAutoKeyword => { + f.debug_tuple("TerminalKind::YulAutoKeyword").finish() + } + TerminalKind::YulBalanceKeyword => { + f.debug_tuple("TerminalKind::YulBalanceKeyword").finish() + } + TerminalKind::YulBaseFeeKeyword => { + f.debug_tuple("TerminalKind::YulBaseFeeKeyword").finish() + } + TerminalKind::YulBlobBaseFeeKeyword => f + .debug_tuple("TerminalKind::YulBlobBaseFeeKeyword") + .finish(), + TerminalKind::YulBlobHashKeyword => { + f.debug_tuple("TerminalKind::YulBlobHashKeyword").finish() + } + TerminalKind::YulBlockHashKeyword => { + f.debug_tuple("TerminalKind::YulBlockHashKeyword").finish() + } + TerminalKind::YulBoolKeyword => { + f.debug_tuple("TerminalKind::YulBoolKeyword").finish() + } + TerminalKind::YulBreakKeyword => { + f.debug_tuple("TerminalKind::YulBreakKeyword").finish() + } + TerminalKind::YulByteKeyword => { + f.debug_tuple("TerminalKind::YulByteKeyword").finish() + } + TerminalKind::YulBytesKeyword => { + f.debug_tuple("TerminalKind::YulBytesKeyword").finish() + } + TerminalKind::YulCallCodeKeyword => { + f.debug_tuple("TerminalKind::YulCallCodeKeyword").finish() + } + TerminalKind::YulCallDataCopyKeyword => f + .debug_tuple("TerminalKind::YulCallDataCopyKeyword") + .finish(), + TerminalKind::YulCallDataKeyword => { + f.debug_tuple("TerminalKind::YulCallDataKeyword").finish() + } + TerminalKind::YulCallDataLoadKeyword => f + .debug_tuple("TerminalKind::YulCallDataLoadKeyword") + .finish(), + TerminalKind::YulCallDataSizeKeyword => f + .debug_tuple("TerminalKind::YulCallDataSizeKeyword") + .finish(), + TerminalKind::YulCallKeyword => { + f.debug_tuple("TerminalKind::YulCallKeyword").finish() + } + TerminalKind::YulCallValueKeyword => { + f.debug_tuple("TerminalKind::YulCallValueKeyword").finish() + } + TerminalKind::YulCallerKeyword => { + f.debug_tuple("TerminalKind::YulCallerKeyword").finish() + } + TerminalKind::YulCaseKeyword => { + f.debug_tuple("TerminalKind::YulCaseKeyword").finish() + } + TerminalKind::YulCatchKeyword => { + f.debug_tuple("TerminalKind::YulCatchKeyword").finish() + } + TerminalKind::YulChainIdKeyword => { + f.debug_tuple("TerminalKind::YulChainIdKeyword").finish() + } + TerminalKind::YulCoinBaseKeyword => { + f.debug_tuple("TerminalKind::YulCoinBaseKeyword").finish() + } + TerminalKind::YulConstantKeyword => { + f.debug_tuple("TerminalKind::YulConstantKeyword").finish() + } + TerminalKind::YulConstructorKeyword => f + .debug_tuple("TerminalKind::YulConstructorKeyword") + .finish(), + TerminalKind::YulContinueKeyword => { + f.debug_tuple("TerminalKind::YulContinueKeyword").finish() + } + TerminalKind::YulContractKeyword => { + f.debug_tuple("TerminalKind::YulContractKeyword").finish() + } + TerminalKind::YulCopyOfKeyword => { + f.debug_tuple("TerminalKind::YulCopyOfKeyword").finish() + } + TerminalKind::YulCreate2Keyword => { + f.debug_tuple("TerminalKind::YulCreate2Keyword").finish() + } + TerminalKind::YulCreateKeyword => { + f.debug_tuple("TerminalKind::YulCreateKeyword").finish() + } + TerminalKind::YulDaysKeyword => { + f.debug_tuple("TerminalKind::YulDaysKeyword").finish() + } + TerminalKind::YulDecimalLiteral => { + f.debug_tuple("TerminalKind::YulDecimalLiteral").finish() + } + TerminalKind::YulDefaultKeyword => { + f.debug_tuple("TerminalKind::YulDefaultKeyword").finish() + } + TerminalKind::YulDefineKeyword => { + f.debug_tuple("TerminalKind::YulDefineKeyword").finish() + } + TerminalKind::YulDelegateCallKeyword => f + .debug_tuple("TerminalKind::YulDelegateCallKeyword") + .finish(), + TerminalKind::YulDeleteKeyword => { + f.debug_tuple("TerminalKind::YulDeleteKeyword").finish() + } + TerminalKind::YulDifficultyKeyword => { + f.debug_tuple("TerminalKind::YulDifficultyKeyword").finish() + } + TerminalKind::YulDivKeyword => { + f.debug_tuple("TerminalKind::YulDivKeyword").finish() + } + TerminalKind::YulDoKeyword => { + f.debug_tuple("TerminalKind::YulDoKeyword").finish() + } + TerminalKind::YulElseKeyword => { + f.debug_tuple("TerminalKind::YulElseKeyword").finish() + } + TerminalKind::YulEmitKeyword => { + f.debug_tuple("TerminalKind::YulEmitKeyword").finish() + } + TerminalKind::YulEnumKeyword => { + f.debug_tuple("TerminalKind::YulEnumKeyword").finish() + } + TerminalKind::YulEqKeyword => { + f.debug_tuple("TerminalKind::YulEqKeyword").finish() + } + TerminalKind::YulEtherKeyword => { + f.debug_tuple("TerminalKind::YulEtherKeyword").finish() + } + TerminalKind::YulEventKeyword => { + f.debug_tuple("TerminalKind::YulEventKeyword").finish() + } + TerminalKind::YulExpKeyword => { + f.debug_tuple("TerminalKind::YulExpKeyword").finish() + } + TerminalKind::YulExtCodeCopyKeyword => f + .debug_tuple("TerminalKind::YulExtCodeCopyKeyword") + .finish(), + TerminalKind::YulExtCodeHashKeyword => f + .debug_tuple("TerminalKind::YulExtCodeHashKeyword") + .finish(), + TerminalKind::YulExtCodeSizeKeyword => f + .debug_tuple("TerminalKind::YulExtCodeSizeKeyword") + .finish(), + TerminalKind::YulExternalKeyword => { + f.debug_tuple("TerminalKind::YulExternalKeyword").finish() + } + TerminalKind::YulFallbackKeyword => { + f.debug_tuple("TerminalKind::YulFallbackKeyword").finish() + } + TerminalKind::YulFalseKeyword => { + f.debug_tuple("TerminalKind::YulFalseKeyword").finish() + } + TerminalKind::YulFinalKeyword => { + f.debug_tuple("TerminalKind::YulFinalKeyword").finish() + } + TerminalKind::YulFinneyKeyword => { + f.debug_tuple("TerminalKind::YulFinneyKeyword").finish() + } + TerminalKind::YulFixedKeyword => { + f.debug_tuple("TerminalKind::YulFixedKeyword").finish() + } + TerminalKind::YulForKeyword => { + f.debug_tuple("TerminalKind::YulForKeyword").finish() + } + TerminalKind::YulFunctionKeyword => { + f.debug_tuple("TerminalKind::YulFunctionKeyword").finish() + } + TerminalKind::YulGasKeyword => { + f.debug_tuple("TerminalKind::YulGasKeyword").finish() + } + TerminalKind::YulGasLimitKeyword => { + f.debug_tuple("TerminalKind::YulGasLimitKeyword").finish() + } + TerminalKind::YulGasPriceKeyword => { + f.debug_tuple("TerminalKind::YulGasPriceKeyword").finish() + } + TerminalKind::YulGtKeyword => { + f.debug_tuple("TerminalKind::YulGtKeyword").finish() + } + TerminalKind::YulGweiKeyword => { + f.debug_tuple("TerminalKind::YulGweiKeyword").finish() + } + TerminalKind::YulHexKeyword => { + f.debug_tuple("TerminalKind::YulHexKeyword").finish() + } + TerminalKind::YulHexLiteral => { + f.debug_tuple("TerminalKind::YulHexLiteral").finish() + } + TerminalKind::YulHoursKeyword => { + f.debug_tuple("TerminalKind::YulHoursKeyword").finish() + } + TerminalKind::YulIdentifier => { + f.debug_tuple("TerminalKind::YulIdentifier").finish() + } + TerminalKind::YulIfKeyword => { + f.debug_tuple("TerminalKind::YulIfKeyword").finish() + } + TerminalKind::YulImmutableKeyword => { + f.debug_tuple("TerminalKind::YulImmutableKeyword").finish() + } + TerminalKind::YulImplementsKeyword => { + f.debug_tuple("TerminalKind::YulImplementsKeyword").finish() + } + TerminalKind::YulImportKeyword => { + f.debug_tuple("TerminalKind::YulImportKeyword").finish() + } + TerminalKind::YulInKeyword => { + f.debug_tuple("TerminalKind::YulInKeyword").finish() + } + TerminalKind::YulIndexedKeyword => { + f.debug_tuple("TerminalKind::YulIndexedKeyword").finish() + } + TerminalKind::YulInlineKeyword => { + f.debug_tuple("TerminalKind::YulInlineKeyword").finish() + } + TerminalKind::YulIntKeyword => { + f.debug_tuple("TerminalKind::YulIntKeyword").finish() + } + TerminalKind::YulInterfaceKeyword => { + f.debug_tuple("TerminalKind::YulInterfaceKeyword").finish() + } + TerminalKind::YulInternalKeyword => { + f.debug_tuple("TerminalKind::YulInternalKeyword").finish() + } + TerminalKind::YulInvalidKeyword => { + f.debug_tuple("TerminalKind::YulInvalidKeyword").finish() + } + TerminalKind::YulIsKeyword => { + f.debug_tuple("TerminalKind::YulIsKeyword").finish() + } + TerminalKind::YulIsZeroKeyword => { + f.debug_tuple("TerminalKind::YulIsZeroKeyword").finish() + } + TerminalKind::YulKeccak256Keyword => { + f.debug_tuple("TerminalKind::YulKeccak256Keyword").finish() + } + TerminalKind::YulLeaveKeyword => { + f.debug_tuple("TerminalKind::YulLeaveKeyword").finish() + } + TerminalKind::YulLetKeyword => { + f.debug_tuple("TerminalKind::YulLetKeyword").finish() + } + TerminalKind::YulLibraryKeyword => { + f.debug_tuple("TerminalKind::YulLibraryKeyword").finish() + } + TerminalKind::YulLog0Keyword => { + f.debug_tuple("TerminalKind::YulLog0Keyword").finish() + } + TerminalKind::YulLog1Keyword => { + f.debug_tuple("TerminalKind::YulLog1Keyword").finish() + } + TerminalKind::YulLog2Keyword => { + f.debug_tuple("TerminalKind::YulLog2Keyword").finish() + } + TerminalKind::YulLog3Keyword => { + f.debug_tuple("TerminalKind::YulLog3Keyword").finish() + } + TerminalKind::YulLog4Keyword => { + f.debug_tuple("TerminalKind::YulLog4Keyword").finish() + } + TerminalKind::YulLtKeyword => { + f.debug_tuple("TerminalKind::YulLtKeyword").finish() + } + TerminalKind::YulMcopyKeyword => { + f.debug_tuple("TerminalKind::YulMcopyKeyword").finish() + } + TerminalKind::YulMloadKeyword => { + f.debug_tuple("TerminalKind::YulMloadKeyword").finish() + } + TerminalKind::YulMsizeKeyword => { + f.debug_tuple("TerminalKind::YulMsizeKeyword").finish() + } + TerminalKind::YulMstore8Keyword => { + f.debug_tuple("TerminalKind::YulMstore8Keyword").finish() + } + TerminalKind::YulMstoreKeyword => { + f.debug_tuple("TerminalKind::YulMstoreKeyword").finish() + } + TerminalKind::YulMacroKeyword => { + f.debug_tuple("TerminalKind::YulMacroKeyword").finish() + } + TerminalKind::YulMappingKeyword => { + f.debug_tuple("TerminalKind::YulMappingKeyword").finish() + } + TerminalKind::YulMatchKeyword => { + f.debug_tuple("TerminalKind::YulMatchKeyword").finish() + } + TerminalKind::YulMemoryKeyword => { + f.debug_tuple("TerminalKind::YulMemoryKeyword").finish() + } + TerminalKind::YulMinutesKeyword => { + f.debug_tuple("TerminalKind::YulMinutesKeyword").finish() + } + TerminalKind::YulModKeyword => { + f.debug_tuple("TerminalKind::YulModKeyword").finish() + } + TerminalKind::YulModifierKeyword => { + f.debug_tuple("TerminalKind::YulModifierKeyword").finish() + } + TerminalKind::YulMulKeyword => { + f.debug_tuple("TerminalKind::YulMulKeyword").finish() + } + TerminalKind::YulMulModKeyword => { + f.debug_tuple("TerminalKind::YulMulModKeyword").finish() + } + TerminalKind::YulMutableKeyword => { + f.debug_tuple("TerminalKind::YulMutableKeyword").finish() + } + TerminalKind::YulNewKeyword => { + f.debug_tuple("TerminalKind::YulNewKeyword").finish() + } + TerminalKind::YulNotKeyword => { + f.debug_tuple("TerminalKind::YulNotKeyword").finish() + } + TerminalKind::YulNullKeyword => { + f.debug_tuple("TerminalKind::YulNullKeyword").finish() + } + TerminalKind::YulNumberKeyword => { + f.debug_tuple("TerminalKind::YulNumberKeyword").finish() + } + TerminalKind::YulOfKeyword => { + f.debug_tuple("TerminalKind::YulOfKeyword").finish() + } + TerminalKind::YulOrKeyword => { + f.debug_tuple("TerminalKind::YulOrKeyword").finish() + } + TerminalKind::YulOriginKeyword => { + f.debug_tuple("TerminalKind::YulOriginKeyword").finish() + } + TerminalKind::YulOverrideKeyword => { + f.debug_tuple("TerminalKind::YulOverrideKeyword").finish() + } + TerminalKind::YulPartialKeyword => { + f.debug_tuple("TerminalKind::YulPartialKeyword").finish() + } + TerminalKind::YulPayableKeyword => { + f.debug_tuple("TerminalKind::YulPayableKeyword").finish() + } + TerminalKind::YulPopKeyword => { + f.debug_tuple("TerminalKind::YulPopKeyword").finish() + } + TerminalKind::YulPragmaKeyword => { + f.debug_tuple("TerminalKind::YulPragmaKeyword").finish() + } + TerminalKind::YulPrevRandaoKeyword => { + f.debug_tuple("TerminalKind::YulPrevRandaoKeyword").finish() + } + TerminalKind::YulPrivateKeyword => { + f.debug_tuple("TerminalKind::YulPrivateKeyword").finish() + } + TerminalKind::YulPromiseKeyword => { + f.debug_tuple("TerminalKind::YulPromiseKeyword").finish() + } + TerminalKind::YulPublicKeyword => { + f.debug_tuple("TerminalKind::YulPublicKeyword").finish() + } + TerminalKind::YulPureKeyword => { + f.debug_tuple("TerminalKind::YulPureKeyword").finish() + } + TerminalKind::YulReceiveKeyword => { + f.debug_tuple("TerminalKind::YulReceiveKeyword").finish() + } + TerminalKind::YulReferenceKeyword => { + f.debug_tuple("TerminalKind::YulReferenceKeyword").finish() + } + TerminalKind::YulRelocatableKeyword => f + .debug_tuple("TerminalKind::YulRelocatableKeyword") + .finish(), + TerminalKind::YulReturnDataCopyKeyword => f + .debug_tuple("TerminalKind::YulReturnDataCopyKeyword") + .finish(), + TerminalKind::YulReturnDataSizeKeyword => f + .debug_tuple("TerminalKind::YulReturnDataSizeKeyword") + .finish(), + TerminalKind::YulReturnKeyword => { + f.debug_tuple("TerminalKind::YulReturnKeyword").finish() + } + TerminalKind::YulReturnsKeyword => { + f.debug_tuple("TerminalKind::YulReturnsKeyword").finish() + } + TerminalKind::YulRevertKeyword => { + f.debug_tuple("TerminalKind::YulRevertKeyword").finish() + } + TerminalKind::YulSdivKeyword => { + f.debug_tuple("TerminalKind::YulSdivKeyword").finish() + } + TerminalKind::YulSloadKeyword => { + f.debug_tuple("TerminalKind::YulSloadKeyword").finish() + } + TerminalKind::YulSmodKeyword => { + f.debug_tuple("TerminalKind::YulSmodKeyword").finish() + } + TerminalKind::YulSstoreKeyword => { + f.debug_tuple("TerminalKind::YulSstoreKeyword").finish() + } + TerminalKind::YulSarKeyword => { + f.debug_tuple("TerminalKind::YulSarKeyword").finish() + } + TerminalKind::YulSealedKeyword => { + f.debug_tuple("TerminalKind::YulSealedKeyword").finish() + } + TerminalKind::YulSecondsKeyword => { + f.debug_tuple("TerminalKind::YulSecondsKeyword").finish() + } + TerminalKind::YulSelfBalanceKeyword => f + .debug_tuple("TerminalKind::YulSelfBalanceKeyword") + .finish(), + TerminalKind::YulSelfDestructKeyword => f + .debug_tuple("TerminalKind::YulSelfDestructKeyword") + .finish(), + TerminalKind::YulSgtKeyword => { + f.debug_tuple("TerminalKind::YulSgtKeyword").finish() + } + TerminalKind::YulSha3Keyword => { + f.debug_tuple("TerminalKind::YulSha3Keyword").finish() + } + TerminalKind::YulShlKeyword => { + f.debug_tuple("TerminalKind::YulShlKeyword").finish() + } + TerminalKind::YulShrKeyword => { + f.debug_tuple("TerminalKind::YulShrKeyword").finish() + } + TerminalKind::YulSignExtendKeyword => { + f.debug_tuple("TerminalKind::YulSignExtendKeyword").finish() + } + TerminalKind::YulSizeOfKeyword => { + f.debug_tuple("TerminalKind::YulSizeOfKeyword").finish() + } + TerminalKind::YulSltKeyword => { + f.debug_tuple("TerminalKind::YulSltKeyword").finish() + } + TerminalKind::YulStaticCallKeyword => { + f.debug_tuple("TerminalKind::YulStaticCallKeyword").finish() + } + TerminalKind::YulStaticKeyword => { + f.debug_tuple("TerminalKind::YulStaticKeyword").finish() + } + TerminalKind::YulStopKeyword => { + f.debug_tuple("TerminalKind::YulStopKeyword").finish() + } + TerminalKind::YulStorageKeyword => { + f.debug_tuple("TerminalKind::YulStorageKeyword").finish() + } + TerminalKind::YulStringKeyword => { + f.debug_tuple("TerminalKind::YulStringKeyword").finish() + } + TerminalKind::YulStructKeyword => { + f.debug_tuple("TerminalKind::YulStructKeyword").finish() + } + TerminalKind::YulSubKeyword => { + f.debug_tuple("TerminalKind::YulSubKeyword").finish() + } + TerminalKind::YulSuicideKeyword => { + f.debug_tuple("TerminalKind::YulSuicideKeyword").finish() + } + TerminalKind::YulSupportsKeyword => { + f.debug_tuple("TerminalKind::YulSupportsKeyword").finish() + } + TerminalKind::YulSwitchKeyword => { + f.debug_tuple("TerminalKind::YulSwitchKeyword").finish() + } + TerminalKind::YulSzaboKeyword => { + f.debug_tuple("TerminalKind::YulSzaboKeyword").finish() + } + TerminalKind::YulTloadKeyword => { + f.debug_tuple("TerminalKind::YulTloadKeyword").finish() + } + TerminalKind::YulTstoreKeyword => { + f.debug_tuple("TerminalKind::YulTstoreKeyword").finish() + } + TerminalKind::YulThrowKeyword => { + f.debug_tuple("TerminalKind::YulThrowKeyword").finish() + } + TerminalKind::YulTimestampKeyword => { + f.debug_tuple("TerminalKind::YulTimestampKeyword").finish() + } + TerminalKind::YulTrueKeyword => { + f.debug_tuple("TerminalKind::YulTrueKeyword").finish() + } + TerminalKind::YulTryKeyword => { + f.debug_tuple("TerminalKind::YulTryKeyword").finish() + } + TerminalKind::YulTypeDefKeyword => { + f.debug_tuple("TerminalKind::YulTypeDefKeyword").finish() + } + TerminalKind::YulTypeKeyword => { + f.debug_tuple("TerminalKind::YulTypeKeyword").finish() + } + TerminalKind::YulTypeOfKeyword => { + f.debug_tuple("TerminalKind::YulTypeOfKeyword").finish() + } + TerminalKind::YulUfixedKeyword => { + f.debug_tuple("TerminalKind::YulUfixedKeyword").finish() + } + TerminalKind::YulUintKeyword => { + f.debug_tuple("TerminalKind::YulUintKeyword").finish() + } + TerminalKind::YulUncheckedKeyword => { + f.debug_tuple("TerminalKind::YulUncheckedKeyword").finish() + } + TerminalKind::YulUsingKeyword => { + f.debug_tuple("TerminalKind::YulUsingKeyword").finish() + } + TerminalKind::YulVarKeyword => { + f.debug_tuple("TerminalKind::YulVarKeyword").finish() + } + TerminalKind::YulViewKeyword => { + f.debug_tuple("TerminalKind::YulViewKeyword").finish() + } + TerminalKind::YulVirtualKeyword => { + f.debug_tuple("TerminalKind::YulVirtualKeyword").finish() + } + TerminalKind::YulWeeksKeyword => { + f.debug_tuple("TerminalKind::YulWeeksKeyword").finish() + } + TerminalKind::YulWeiKeyword => { + f.debug_tuple("TerminalKind::YulWeiKeyword").finish() + } + TerminalKind::YulWhileKeyword => { + f.debug_tuple("TerminalKind::YulWhileKeyword").finish() + } + TerminalKind::YulXorKeyword => { + f.debug_tuple("TerminalKind::YulXorKeyword").finish() + } + TerminalKind::YulYearsKeyword => { + f.debug_tuple("TerminalKind::YulYearsKeyword").finish() + } + } + } + } + + impl TerminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u16) -> TerminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => TerminalKind::Skipped, + 1 => TerminalKind::AbicoderKeyword, + 2 => TerminalKind::AbstractKeyword, + 3 => TerminalKind::AddressKeyword, + 4 => TerminalKind::AfterKeyword, + 5 => TerminalKind::AliasKeyword, + 6 => TerminalKind::Ampersand, + 7 => TerminalKind::AmpersandAmpersand, + 8 => TerminalKind::AmpersandEqual, + 9 => TerminalKind::AnonymousKeyword, + 10 => TerminalKind::ApplyKeyword, + 11 => TerminalKind::AsKeyword, + 12 => TerminalKind::AssemblyKeyword, + 13 => TerminalKind::Asterisk, + 14 => TerminalKind::AsteriskAsterisk, + 15 => TerminalKind::AsteriskEqual, + 16 => TerminalKind::AutoKeyword, + 17 => TerminalKind::Bang, + 18 => TerminalKind::BangEqual, + 19 => TerminalKind::Bar, + 20 => TerminalKind::BarBar, + 21 => TerminalKind::BarEqual, + 22 => TerminalKind::BoolKeyword, + 23 => TerminalKind::BreakKeyword, + 24 => TerminalKind::ByteKeyword, + 25 => TerminalKind::BytesKeyword, + 26 => TerminalKind::CallDataKeyword, + 27 => TerminalKind::Caret, + 28 => TerminalKind::CaretEqual, + 29 => TerminalKind::CaseKeyword, + 30 => TerminalKind::CatchKeyword, + 31 => TerminalKind::CloseBrace, + 32 => TerminalKind::CloseBracket, + 33 => TerminalKind::CloseParen, + 34 => TerminalKind::Colon, + 35 => TerminalKind::ColonEqual, + 36 => TerminalKind::Comma, + 37 => TerminalKind::ConstantKeyword, + 38 => TerminalKind::ConstructorKeyword, + 39 => TerminalKind::ContinueKeyword, + 40 => TerminalKind::ContractKeyword, + 41 => TerminalKind::CopyOfKeyword, + 42 => TerminalKind::DaysKeyword, + 43 => TerminalKind::DecimalLiteral, + 44 => TerminalKind::DefaultKeyword, + 45 => TerminalKind::DefineKeyword, + 46 => TerminalKind::DeleteKeyword, + 47 => TerminalKind::DoKeyword, + 48 => TerminalKind::DoubleQuotedHexStringLiteral, + 49 => TerminalKind::DoubleQuotedStringLiteral, + 50 => TerminalKind::DoubleQuotedUnicodeStringLiteral, + 51 => TerminalKind::DoubleQuotedVersionLiteral, + 52 => TerminalKind::ElseKeyword, + 53 => TerminalKind::EmitKeyword, + 54 => TerminalKind::EndOfLine, + 55 => TerminalKind::EnumKeyword, + 56 => TerminalKind::Equal, + 57 => TerminalKind::EqualEqual, + 58 => TerminalKind::EqualGreaterThan, + 59 => TerminalKind::ErrorKeyword, + 60 => TerminalKind::EtherKeyword, + 61 => TerminalKind::EventKeyword, + 62 => TerminalKind::ExperimentalKeyword, + 63 => TerminalKind::ExternalKeyword, + 64 => TerminalKind::FallbackKeyword, + 65 => TerminalKind::FalseKeyword, + 66 => TerminalKind::FinalKeyword, + 67 => TerminalKind::FinneyKeyword, + 68 => TerminalKind::FixedKeyword, + 69 => TerminalKind::ForKeyword, + 70 => TerminalKind::FromKeyword, + 71 => TerminalKind::FunctionKeyword, + 72 => TerminalKind::GlobalKeyword, + 73 => TerminalKind::GreaterThan, + 74 => TerminalKind::GreaterThanEqual, + 75 => TerminalKind::GreaterThanGreaterThan, + 76 => TerminalKind::GreaterThanGreaterThanEqual, + 77 => TerminalKind::GreaterThanGreaterThanGreaterThan, + 78 => TerminalKind::GreaterThanGreaterThanGreaterThanEqual, + 79 => TerminalKind::GweiKeyword, + 80 => TerminalKind::HexKeyword, + 81 => TerminalKind::HexLiteral, + 82 => TerminalKind::HoursKeyword, + 83 => TerminalKind::Identifier, + 84 => TerminalKind::IfKeyword, + 85 => TerminalKind::ImmutableKeyword, + 86 => TerminalKind::ImplementsKeyword, + 87 => TerminalKind::ImportKeyword, + 88 => TerminalKind::InKeyword, + 89 => TerminalKind::IndexedKeyword, + 90 => TerminalKind::InlineKeyword, + 91 => TerminalKind::IntKeyword, + 92 => TerminalKind::InterfaceKeyword, + 93 => TerminalKind::InternalKeyword, + 94 => TerminalKind::IsKeyword, + 95 => TerminalKind::LessThan, + 96 => TerminalKind::LessThanEqual, + 97 => TerminalKind::LessThanLessThan, + 98 => TerminalKind::LessThanLessThanEqual, + 99 => TerminalKind::LetKeyword, + 100 => TerminalKind::LibraryKeyword, + 101 => TerminalKind::MacroKeyword, + 102 => TerminalKind::MappingKeyword, + 103 => TerminalKind::MatchKeyword, + 104 => TerminalKind::MemoryKeyword, + 105 => TerminalKind::Minus, + 106 => TerminalKind::MinusEqual, + 107 => TerminalKind::MinusGreaterThan, + 108 => TerminalKind::MinusMinus, + 109 => TerminalKind::MinutesKeyword, + 110 => TerminalKind::ModifierKeyword, + 111 => TerminalKind::MultiLineComment, + 112 => TerminalKind::MultiLineNatSpecComment, + 113 => TerminalKind::MutableKeyword, + 114 => TerminalKind::NewKeyword, + 115 => TerminalKind::NullKeyword, + 116 => TerminalKind::OfKeyword, + 117 => TerminalKind::OpenBrace, + 118 => TerminalKind::OpenBracket, + 119 => TerminalKind::OpenParen, + 120 => TerminalKind::OverrideKeyword, + 121 => TerminalKind::PartialKeyword, + 122 => TerminalKind::PayableKeyword, + 123 => TerminalKind::Percent, + 124 => TerminalKind::PercentEqual, + 125 => TerminalKind::Period, + 126 => TerminalKind::Plus, + 127 => TerminalKind::PlusEqual, + 128 => TerminalKind::PlusPlus, + 129 => TerminalKind::PragmaKeyword, + 130 => TerminalKind::PrivateKeyword, + 131 => TerminalKind::PromiseKeyword, + 132 => TerminalKind::PublicKeyword, + 133 => TerminalKind::PureKeyword, + 134 => TerminalKind::QuestionMark, + 135 => TerminalKind::ReceiveKeyword, + 136 => TerminalKind::ReferenceKeyword, + 137 => TerminalKind::RelocatableKeyword, + 138 => TerminalKind::ReturnKeyword, + 139 => TerminalKind::ReturnsKeyword, + 140 => TerminalKind::RevertKeyword, + 141 => TerminalKind::SealedKeyword, + 142 => TerminalKind::SecondsKeyword, + 143 => TerminalKind::Semicolon, + 144 => TerminalKind::SingleLineComment, + 145 => TerminalKind::SingleLineNatSpecComment, + 146 => TerminalKind::SingleQuotedHexStringLiteral, + 147 => TerminalKind::SingleQuotedStringLiteral, + 148 => TerminalKind::SingleQuotedUnicodeStringLiteral, + 149 => TerminalKind::SingleQuotedVersionLiteral, + 150 => TerminalKind::SizeOfKeyword, + 151 => TerminalKind::Slash, + 152 => TerminalKind::SlashEqual, + 153 => TerminalKind::SolidityKeyword, + 154 => TerminalKind::StaticKeyword, + 155 => TerminalKind::StorageKeyword, + 156 => TerminalKind::StringKeyword, + 157 => TerminalKind::StructKeyword, + 158 => TerminalKind::SupportsKeyword, + 159 => TerminalKind::SwitchKeyword, + 160 => TerminalKind::SzaboKeyword, + 161 => TerminalKind::ThrowKeyword, + 162 => TerminalKind::Tilde, + 163 => TerminalKind::TrueKeyword, + 164 => TerminalKind::TryKeyword, + 165 => TerminalKind::TypeDefKeyword, + 166 => TerminalKind::TypeKeyword, + 167 => TerminalKind::TypeOfKeyword, + 168 => TerminalKind::UfixedKeyword, + 169 => TerminalKind::UintKeyword, + 170 => TerminalKind::UncheckedKeyword, + 171 => TerminalKind::UsingKeyword, + 172 => TerminalKind::VarKeyword, + 173 => TerminalKind::VersionSpecifier, + 174 => TerminalKind::ViewKeyword, + 175 => TerminalKind::VirtualKeyword, + 176 => TerminalKind::WeeksKeyword, + 177 => TerminalKind::WeiKeyword, + 178 => TerminalKind::WhileKeyword, + 179 => TerminalKind::Whitespace, + 180 => TerminalKind::YearsKeyword, + 181 => TerminalKind::YulAbstractKeyword, + 182 => TerminalKind::YulAddKeyword, + 183 => TerminalKind::YulAddModKeyword, + 184 => TerminalKind::YulAddressKeyword, + 185 => TerminalKind::YulAfterKeyword, + 186 => TerminalKind::YulAliasKeyword, + 187 => TerminalKind::YulAndKeyword, + 188 => TerminalKind::YulAnonymousKeyword, + 189 => TerminalKind::YulApplyKeyword, + 190 => TerminalKind::YulAsKeyword, + 191 => TerminalKind::YulAssemblyKeyword, + 192 => TerminalKind::YulAutoKeyword, + 193 => TerminalKind::YulBalanceKeyword, + 194 => TerminalKind::YulBaseFeeKeyword, + 195 => TerminalKind::YulBlobBaseFeeKeyword, + 196 => TerminalKind::YulBlobHashKeyword, + 197 => TerminalKind::YulBlockHashKeyword, + 198 => TerminalKind::YulBoolKeyword, + 199 => TerminalKind::YulBreakKeyword, + 200 => TerminalKind::YulByteKeyword, + 201 => TerminalKind::YulBytesKeyword, + 202 => TerminalKind::YulCallCodeKeyword, + 203 => TerminalKind::YulCallDataCopyKeyword, + 204 => TerminalKind::YulCallDataKeyword, + 205 => TerminalKind::YulCallDataLoadKeyword, + 206 => TerminalKind::YulCallDataSizeKeyword, + 207 => TerminalKind::YulCallKeyword, + 208 => TerminalKind::YulCallValueKeyword, + 209 => TerminalKind::YulCallerKeyword, + 210 => TerminalKind::YulCaseKeyword, + 211 => TerminalKind::YulCatchKeyword, + 212 => TerminalKind::YulChainIdKeyword, + 213 => TerminalKind::YulCoinBaseKeyword, + 214 => TerminalKind::YulConstantKeyword, + 215 => TerminalKind::YulConstructorKeyword, + 216 => TerminalKind::YulContinueKeyword, + 217 => TerminalKind::YulContractKeyword, + 218 => TerminalKind::YulCopyOfKeyword, + 219 => TerminalKind::YulCreate2Keyword, + 220 => TerminalKind::YulCreateKeyword, + 221 => TerminalKind::YulDaysKeyword, + 222 => TerminalKind::YulDecimalLiteral, + 223 => TerminalKind::YulDefaultKeyword, + 224 => TerminalKind::YulDefineKeyword, + 225 => TerminalKind::YulDelegateCallKeyword, + 226 => TerminalKind::YulDeleteKeyword, + 227 => TerminalKind::YulDifficultyKeyword, + 228 => TerminalKind::YulDivKeyword, + 229 => TerminalKind::YulDoKeyword, + 230 => TerminalKind::YulElseKeyword, + 231 => TerminalKind::YulEmitKeyword, + 232 => TerminalKind::YulEnumKeyword, + 233 => TerminalKind::YulEqKeyword, + 234 => TerminalKind::YulEtherKeyword, + 235 => TerminalKind::YulEventKeyword, + 236 => TerminalKind::YulExpKeyword, + 237 => TerminalKind::YulExtCodeCopyKeyword, + 238 => TerminalKind::YulExtCodeHashKeyword, + 239 => TerminalKind::YulExtCodeSizeKeyword, + 240 => TerminalKind::YulExternalKeyword, + 241 => TerminalKind::YulFallbackKeyword, + 242 => TerminalKind::YulFalseKeyword, + 243 => TerminalKind::YulFinalKeyword, + 244 => TerminalKind::YulFinneyKeyword, + 245 => TerminalKind::YulFixedKeyword, + 246 => TerminalKind::YulForKeyword, + 247 => TerminalKind::YulFunctionKeyword, + 248 => TerminalKind::YulGasKeyword, + 249 => TerminalKind::YulGasLimitKeyword, + 250 => TerminalKind::YulGasPriceKeyword, + 251 => TerminalKind::YulGtKeyword, + 252 => TerminalKind::YulGweiKeyword, + 253 => TerminalKind::YulHexKeyword, + 254 => TerminalKind::YulHexLiteral, + 255 => TerminalKind::YulHoursKeyword, + 256 => TerminalKind::YulIdentifier, + 257 => TerminalKind::YulIfKeyword, + 258 => TerminalKind::YulImmutableKeyword, + 259 => TerminalKind::YulImplementsKeyword, + 260 => TerminalKind::YulImportKeyword, + 261 => TerminalKind::YulInKeyword, + 262 => TerminalKind::YulIndexedKeyword, + 263 => TerminalKind::YulInlineKeyword, + 264 => TerminalKind::YulIntKeyword, + 265 => TerminalKind::YulInterfaceKeyword, + 266 => TerminalKind::YulInternalKeyword, + 267 => TerminalKind::YulInvalidKeyword, + 268 => TerminalKind::YulIsKeyword, + 269 => TerminalKind::YulIsZeroKeyword, + 270 => TerminalKind::YulKeccak256Keyword, + 271 => TerminalKind::YulLeaveKeyword, + 272 => TerminalKind::YulLetKeyword, + 273 => TerminalKind::YulLibraryKeyword, + 274 => TerminalKind::YulLog0Keyword, + 275 => TerminalKind::YulLog1Keyword, + 276 => TerminalKind::YulLog2Keyword, + 277 => TerminalKind::YulLog3Keyword, + 278 => TerminalKind::YulLog4Keyword, + 279 => TerminalKind::YulLtKeyword, + 280 => TerminalKind::YulMcopyKeyword, + 281 => TerminalKind::YulMloadKeyword, + 282 => TerminalKind::YulMsizeKeyword, + 283 => TerminalKind::YulMstore8Keyword, + 284 => TerminalKind::YulMstoreKeyword, + 285 => TerminalKind::YulMacroKeyword, + 286 => TerminalKind::YulMappingKeyword, + 287 => TerminalKind::YulMatchKeyword, + 288 => TerminalKind::YulMemoryKeyword, + 289 => TerminalKind::YulMinutesKeyword, + 290 => TerminalKind::YulModKeyword, + 291 => TerminalKind::YulModifierKeyword, + 292 => TerminalKind::YulMulKeyword, + 293 => TerminalKind::YulMulModKeyword, + 294 => TerminalKind::YulMutableKeyword, + 295 => TerminalKind::YulNewKeyword, + 296 => TerminalKind::YulNotKeyword, + 297 => TerminalKind::YulNullKeyword, + 298 => TerminalKind::YulNumberKeyword, + 299 => TerminalKind::YulOfKeyword, + 300 => TerminalKind::YulOrKeyword, + 301 => TerminalKind::YulOriginKeyword, + 302 => TerminalKind::YulOverrideKeyword, + 303 => TerminalKind::YulPartialKeyword, + 304 => TerminalKind::YulPayableKeyword, + 305 => TerminalKind::YulPopKeyword, + 306 => TerminalKind::YulPragmaKeyword, + 307 => TerminalKind::YulPrevRandaoKeyword, + 308 => TerminalKind::YulPrivateKeyword, + 309 => TerminalKind::YulPromiseKeyword, + 310 => TerminalKind::YulPublicKeyword, + 311 => TerminalKind::YulPureKeyword, + 312 => TerminalKind::YulReceiveKeyword, + 313 => TerminalKind::YulReferenceKeyword, + 314 => TerminalKind::YulRelocatableKeyword, + 315 => TerminalKind::YulReturnDataCopyKeyword, + 316 => TerminalKind::YulReturnDataSizeKeyword, + 317 => TerminalKind::YulReturnKeyword, + 318 => TerminalKind::YulReturnsKeyword, + 319 => TerminalKind::YulRevertKeyword, + 320 => TerminalKind::YulSdivKeyword, + 321 => TerminalKind::YulSloadKeyword, + 322 => TerminalKind::YulSmodKeyword, + 323 => TerminalKind::YulSstoreKeyword, + 324 => TerminalKind::YulSarKeyword, + 325 => TerminalKind::YulSealedKeyword, + 326 => TerminalKind::YulSecondsKeyword, + 327 => TerminalKind::YulSelfBalanceKeyword, + 328 => TerminalKind::YulSelfDestructKeyword, + 329 => TerminalKind::YulSgtKeyword, + 330 => TerminalKind::YulSha3Keyword, + 331 => TerminalKind::YulShlKeyword, + 332 => TerminalKind::YulShrKeyword, + 333 => TerminalKind::YulSignExtendKeyword, + 334 => TerminalKind::YulSizeOfKeyword, + 335 => TerminalKind::YulSltKeyword, + 336 => TerminalKind::YulStaticCallKeyword, + 337 => TerminalKind::YulStaticKeyword, + 338 => TerminalKind::YulStopKeyword, + 339 => TerminalKind::YulStorageKeyword, + 340 => TerminalKind::YulStringKeyword, + 341 => TerminalKind::YulStructKeyword, + 342 => TerminalKind::YulSubKeyword, + 343 => TerminalKind::YulSuicideKeyword, + 344 => TerminalKind::YulSupportsKeyword, + 345 => TerminalKind::YulSwitchKeyword, + 346 => TerminalKind::YulSzaboKeyword, + 347 => TerminalKind::YulTloadKeyword, + 348 => TerminalKind::YulTstoreKeyword, + 349 => TerminalKind::YulThrowKeyword, + 350 => TerminalKind::YulTimestampKeyword, + 351 => TerminalKind::YulTrueKeyword, + 352 => TerminalKind::YulTryKeyword, + 353 => TerminalKind::YulTypeDefKeyword, + 354 => TerminalKind::YulTypeKeyword, + 355 => TerminalKind::YulTypeOfKeyword, + 356 => TerminalKind::YulUfixedKeyword, + 357 => TerminalKind::YulUintKeyword, + 358 => TerminalKind::YulUncheckedKeyword, + 359 => TerminalKind::YulUsingKeyword, + 360 => TerminalKind::YulVarKeyword, + 361 => TerminalKind::YulViewKeyword, + 362 => TerminalKind::YulVirtualKeyword, + 363 => TerminalKind::YulWeeksKeyword, + 364 => TerminalKind::YulWeiKeyword, + 365 => TerminalKind::YulWhileKeyword, + 366 => TerminalKind::YulXorKeyword, + 367 => TerminalKind::YulYearsKeyword, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Language { + handle: _rt::Resource, + } + + type _LanguageRep = Option; + + impl Language { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Language`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _LanguageRep = Some(val); + let ptr: *mut _LanguageRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestLanguage` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _LanguageRep); + } + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Language`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct LanguageBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Language>, + } + + impl<'a> LanguageBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Language { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]language"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseError { + handle: _rt::Resource, + } + + type _ParseErrorRep = Option; + + impl ParseError { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseError`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseErrorRep = Some(val); + let ptr: *mut _ParseErrorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseError` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseErrorRep); + } + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseError`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseErrorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseError>, + } + + impl<'a> ParseErrorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseError { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutput { + handle: _rt::Resource, + } + + type _ParseOutputRep = Option; + + impl ParseOutput { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseOutput`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseOutputRep = Some(val); + let ptr: *mut _ParseOutputRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseOutput` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseOutputRep); + } + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseOutput`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutputBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseOutput>, + } + + impl<'a> ParseOutputBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseOutput { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-output"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNode { + handle: _rt::Resource, + } + + type _NonterminalNodeRep = Option; + + impl NonterminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `NonterminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _NonterminalNodeRep = Some(val); + let ptr: *mut _NonterminalNodeRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestNonterminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _NonterminalNodeRep); + } + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`NonterminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a NonterminalNode>, + } + + impl<'a> NonterminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for NonterminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]nonterminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNode { + handle: _rt::Resource, + } + + type _TerminalNodeRep = Option; + + impl TerminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `TerminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _TerminalNodeRep = Some(val); + let ptr: *mut _TerminalNodeRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestTerminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _TerminalNodeRep); + } + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`TerminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a TerminalNode>, + } + + impl<'a> TerminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for TerminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]terminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub enum Node { + Nonterminal(NonterminalNode), + Terminal(TerminalNode), + } + impl ::core::fmt::Debug for Node { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Node::Nonterminal(e) => { + f.debug_tuple("Node::Nonterminal").field(e).finish() + } + Node::Terminal(e) => f.debug_tuple("Node::Terminal").field(e).finish(), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Cursor { + handle: _rt::Resource, + } + + type _CursorRep = Option; + + impl Cursor { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Cursor`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CursorRep = Some(val); + let ptr: *mut _CursorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCursor` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CursorRep); + } + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Cursor`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CursorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Cursor>, + } + + impl<'a> CursorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Cursor { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]cursor"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Query { + handle: _rt::Resource, + } + + type _QueryRep = Option; + + impl Query { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Query`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryRep = Some(val); + let ptr: *mut _QueryRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQuery` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryRep); + } + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Query`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Query>, + } + + impl<'a> QueryBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Query { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Clone)] + pub struct QueryError { + pub message: _rt::String, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryError") + .field("message", &self.message) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + impl ::core::fmt::Display for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for QueryError {} + pub struct QueryMatch { + pub query_number: u32, + pub captures: _rt::Vec<(_rt::String, _rt::Vec)>, + } + impl ::core::fmt::Debug for QueryMatch { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryMatch") + .field("query-number", &self.query_number) + .field("captures", &self.captures) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIterator { + handle: _rt::Resource, + } + + type _QueryMatchIteratorRep = Option; + + impl QueryMatchIterator { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `QueryMatchIterator`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryMatchIteratorRep = Some(val); + let ptr: *mut _QueryMatchIteratorRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQueryMatchIterator` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryMatchIteratorRep); + } + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`QueryMatchIterator`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIteratorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a QueryMatchIterator>, + } + + impl<'a> QueryMatchIteratorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for QueryMatchIterator { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query-match-iterator"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Severity { + Error, + Warning, + Information, + Hint, + } + impl ::core::fmt::Debug for Severity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Severity::Error => f.debug_tuple("Severity::Error").finish(), + Severity::Warning => f.debug_tuple("Severity::Warning").finish(), + Severity::Information => { + f.debug_tuple("Severity::Information").finish() + } + Severity::Hint => f.debug_tuple("Severity::Hint").finish(), + } + } + } + + impl Severity { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Severity { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Severity::Error, + 1 => Severity::Warning, + 2 => Severity::Information, + 3 => Severity::Hint, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextIndex { + pub utf8: u32, + pub utf16: u32, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for TextIndex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextIndex") + .field("utf8", &self.utf8) + .field("utf16", &self.utf16) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextRange { + pub start: TextIndex, + pub end: TextIndex, + } + impl ::core::fmt::Debug for TextRange { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextRange") + .field("start", &self.start) + .field("end", &self.end) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_supported_versions_cabi( + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::supported_versions(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_supported_versions( + arg0: *mut u8, + ) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_new_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::new(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_new(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_version_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::version(LanguageBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_language_version( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_parse_cabi( + arg0: *mut u8, + arg1: i32, + arg2: *mut u8, + arg3: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg3; + let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); + let result1 = T::parse( + LanguageBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + _rt::string_lift(bytes0), + ); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_severity_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::severity(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_message_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::message(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_error_message( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_tree_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::tree(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_errors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::errors(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_output_errors( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_is_valid_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_valid(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_create_tree_cursor_cabi< + T: GuestParseOutput, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::create_tree_cursor(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_text_len_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::text_len(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_children_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::children(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + match e { + Node::Nonterminal(e) => { + *base.add(0).cast::() = (0i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + } + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_children< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_create_cursor_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::create_cursor( + NonterminalNodeBorrow::lift(arg0 as u32 as usize).get(), + TextIndex { + utf8: arg1 as u32, + utf16: arg2 as u32, + line: arg3 as u32, + column: arg4 as u32, + }, + ); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_unparse_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::unparse(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_unparse< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_len_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_len(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_terminal_node_text( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_reset_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::reset(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_complete_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::complete(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_is_completed_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_completed(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_clone_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::clone(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_spawn_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::spawn(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_node_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::node(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_label_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::label(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(1).cast::() = (e.clone() as i32) as u8; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_offset_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_offset(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_depth_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::depth(CursorBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_ancestors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::ancestors(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_cursor_ancestors(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_non_descendent_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_non_descendent( + CursorBorrow::lift(arg0 as u32 as usize).get(), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_previous(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_parent_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_parent(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_first_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_first_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_last_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_last_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_nth_child_cabi( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_nth_child( + CursorBorrow::lift(arg0 as u32 as usize).get(), + arg1 as u32, + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_previous_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_terminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_terminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + TerminalKind::_lift(arg1 as u16), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 2); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + TerminalKind::_lift(l0 as u16) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 2, 2); + let result2 = T::go_to_next_terminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_nonterminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_nonterminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 1); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + NonterminalKind::_lift(l0 as u8) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 1, 1); + let result2 = T::go_to_next_nonterminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_query_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 4); + let e1 = { + let l0 = *base.add(0).cast::(); + + QueryBorrow::lift(l0 as u32 as usize) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 4, 4); + let result2 = T::query(CursorBorrow::lift(arg0 as u32 as usize).get(), result1); + (result2).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_query_parse_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::parse(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let QueryError { + message: message3, + line: line3, + column: column3, + } = e; + let vec4 = (message3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(8).cast::() = len4; + *ptr2.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + *ptr2.add(12).cast::() = _rt::as_i32(line3); + *ptr2.add(16).cast::() = _rt::as_i32(column3); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_query_parse(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_query_match_iterator_next_cabi< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::next(QueryMatchIteratorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let QueryMatch { + query_number: query_number2, + captures: captures2, + } = e; + *ptr1.add(4).cast::() = _rt::as_i32(query_number2); + let vec6 = captures2; + let len6 = vec6.len(); + let layout6 = + _rt::alloc::Layout::from_size_align_unchecked(vec6.len() * 16, 4); + let result6 = if layout6.size() != 0 { + let ptr = _rt::alloc::alloc(layout6).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout6); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6.add(i * 16); + { + let (t3_0, t3_1) = e; + let vec4 = (t3_0.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(4).cast::() = len4; + *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + let vec5 = t3_1; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked( + vec5.len() * 4, + 4, + ); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = result5; + } + } + *ptr1.add(12).cast::() = len6; + *ptr1.add(8).cast::<*mut u8>() = result6; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_query_match_iterator_next< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l6 = *arg0.add(8).cast::<*mut u8>(); + let l7 = *arg0.add(12).cast::(); + let base8 = l6; + let len8 = l7; + for i in 0..len8 { + let base = base8.add(i * 16); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(8).cast::<*mut u8>(); + let l4 = *base.add(12).cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); + } + } + _rt::cabi_dealloc(base8, len8 * 16, 4); + } + } + } + pub trait Guest { + type Language: GuestLanguage; + type ParseError: GuestParseError; + type ParseOutput: GuestParseOutput; + type NonterminalNode: GuestNonterminalNode; + type TerminalNode: GuestTerminalNode; + type Cursor: GuestCursor; + type Query: GuestQuery; + type QueryMatchIterator: GuestQueryMatchIterator; + } + pub trait GuestLanguage: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]language"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]language"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn supported_versions() -> _rt::Vec<_rt::String>; + fn new(version: _rt::String) -> Result; + fn version(&self) -> _rt::String; + fn parse(&self, kind: NonterminalKind, input: _rt::String) -> ParseOutput; + } + pub trait GuestParseError: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-error"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-error"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + /// is-a diagnostic + fn severity(&self) -> Severity; + fn text_range(&self) -> TextRange; + fn message(&self) -> _rt::String; + } + pub trait GuestParseOutput: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-output"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-output"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn tree(&self) -> Node; + fn errors(&self) -> _rt::Vec; + fn is_valid(&self) -> bool; + fn create_tree_cursor(&self) -> Cursor; + } + pub trait GuestNonterminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]nonterminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]nonterminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> NonterminalKind; + fn text_len(&self) -> TextIndex; + fn children(&self) -> _rt::Vec; + fn create_cursor(&self, text_offset: TextIndex) -> Cursor; + fn unparse(&self) -> _rt::String; + } + pub trait GuestTerminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]terminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]terminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> TerminalKind; + fn text_len(&self) -> TextIndex; + fn text(&self) -> _rt::String; + } + pub trait GuestCursor: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]cursor"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]cursor"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn reset(&self); + fn complete(&self); + fn is_completed(&self) -> bool; + fn clone(&self) -> Cursor; + fn spawn(&self) -> Cursor; + fn node(&self) -> Node; + fn label(&self) -> Option; + fn text_offset(&self) -> TextIndex; + fn text_range(&self) -> TextRange; + fn depth(&self) -> u32; + fn ancestors(&self) -> _rt::Vec; + fn go_to_next(&self) -> bool; + fn go_to_next_non_descendent(&self) -> bool; + fn go_to_previous(&self) -> bool; + fn go_to_parent(&self) -> bool; + fn go_to_first_child(&self) -> bool; + fn go_to_last_child(&self) -> bool; + fn go_to_nth_child(&self, child_number: u32) -> bool; + fn go_to_next_sibling(&self) -> bool; + fn go_to_previous_sibling(&self) -> bool; + fn go_to_next_terminal(&self) -> bool; + fn go_to_next_terminal_with_kind(&self, kind: TerminalKind) -> bool; + fn go_to_next_terminal_with_kinds(&self, kinds: _rt::Vec) + -> bool; + fn go_to_next_nonterminal(&self) -> bool; + fn go_to_next_nonterminal_with_kind(&self, kind: NonterminalKind) -> bool; + fn go_to_next_nonterminal_with_kinds( + &self, + kinds: _rt::Vec, + ) -> bool; + fn query(&self, queries: _rt::Vec>) -> QueryMatchIterator; + } + pub trait GuestQuery: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn parse(text: _rt::String) -> Result; + } + pub trait GuestQueryMatchIterator: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query-match-iterator"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query-match-iterator"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn next(&self) -> Option; + } + #[doc(hidden)] + #[macro_export] + macro_rules! __export_nomic_slang_parser_1_0_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn export_static_language_supported_versions() -> *mut u8 { + $($path_to_types)*::_export_static_language_supported_versions_cabi::<<$ty as $($path_to_types)*::Guest>::Language>() + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn _post_return_static_language_supported_versions(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_supported_versions::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn export_static_language_new(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_language_new_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn _post_return_static_language_new(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_new::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn export_method_language_version(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_language_version_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn _post_return_method_language_version(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_language_version::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.parse"] + unsafe extern "C" fn export_method_language_parse(arg0: *mut u8,arg1: i32,arg2: *mut u8,arg3: usize,) -> i32 { + $($path_to_types)*::_export_method_language_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1, arg2, arg3) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.severity"] + unsafe extern "C" fn export_method_parse_error_severity(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_error_severity_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.text-range"] + unsafe extern "C" fn export_method_parse_error_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn export_method_parse_error_message(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_message_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn _post_return_method_parse_error_message(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_error_message::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.tree"] + unsafe extern "C" fn export_method_parse_output_tree(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_tree_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn export_method_parse_output_errors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_errors_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn _post_return_method_parse_output_errors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_output_errors::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.is-valid"] + unsafe extern "C" fn export_method_parse_output_is_valid(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_is_valid_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.create-tree-cursor"] + unsafe extern "C" fn export_method_parse_output_create_tree_cursor(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_create_tree_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.kind"] + unsafe extern "C" fn export_method_nonterminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.text-len"] + unsafe extern "C" fn export_method_nonterminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn export_method_nonterminal_node_children(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_children_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn _post_return_method_nonterminal_node_children(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_children::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.create-cursor"] + unsafe extern "C" fn export_method_nonterminal_node_create_cursor(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_create_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0, arg1, arg2, arg3, arg4) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn export_method_nonterminal_node_unparse(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_unparse_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn _post_return_method_nonterminal_node_unparse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_unparse::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.kind"] + unsafe extern "C" fn export_method_terminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_terminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text-len"] + unsafe extern "C" fn export_method_terminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn export_method_terminal_node_text(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn _post_return_method_terminal_node_text(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_terminal_node_text::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.reset"] + unsafe extern "C" fn export_method_cursor_reset(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_reset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.complete"] + unsafe extern "C" fn export_method_cursor_complete(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_complete_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.is-completed"] + unsafe extern "C" fn export_method_cursor_is_completed(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_is_completed_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.clone"] + unsafe extern "C" fn export_method_cursor_clone(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_clone_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.spawn"] + unsafe extern "C" fn export_method_cursor_spawn(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_spawn_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.node"] + unsafe extern "C" fn export_method_cursor_node(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_node_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.label"] + unsafe extern "C" fn export_method_cursor_label(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_label_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-offset"] + unsafe extern "C" fn export_method_cursor_text_offset(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_offset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-range"] + unsafe extern "C" fn export_method_cursor_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.depth"] + unsafe extern "C" fn export_method_cursor_depth(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_depth_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn export_method_cursor_ancestors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_ancestors_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn _post_return_method_cursor_ancestors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_cursor_ancestors::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next"] + unsafe extern "C" fn export_method_cursor_go_to_next(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-non-descendent"] + unsafe extern "C" fn export_method_cursor_go_to_next_non_descendent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_non_descendent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous"] + unsafe extern "C" fn export_method_cursor_go_to_previous(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-parent"] + unsafe extern "C" fn export_method_cursor_go_to_parent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_parent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-first-child"] + unsafe extern "C" fn export_method_cursor_go_to_first_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_first_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-last-child"] + unsafe extern "C" fn export_method_cursor_go_to_last_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_last_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-nth-child"] + unsafe extern "C" fn export_method_cursor_go_to_nth_child(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_nth_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_next_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_previous_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.query"] + unsafe extern "C" fn export_method_cursor_query(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_query_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn export_static_query_parse(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_query_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Query>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn _post_return_static_query_parse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_query_parse::<<$ty as $($path_to_types)*::Guest>::Query>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn export_method_query_match_iterator_next(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_query_match_iterator_next_cabi::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn _post_return_method_query_match_iterator_next(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_query_match_iterator_next::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]language"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Language::dtor::< + <$ty as $($path_to_types)*::Guest>::Language + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-error"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseError::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseError + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-output"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseOutput::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseOutput + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]nonterminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::NonterminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::NonterminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]terminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::TerminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::TerminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]cursor"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Cursor::dtor::< + <$ty as $($path_to_types)*::Guest>::Cursor + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Query::dtor::< + <$ty as $($path_to_types)*::Guest>::Query + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query-match-iterator"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::QueryMatchIterator::dtor::< + <$ty as $($path_to_types)*::Guest>::QueryMatchIterator + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub use __export_nomic_slang_parser_1_0_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 32]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 32]); + } + } + } +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + pub use alloc_crate::boxed::Box; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen::rt::run_ctors_once(); + } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] +#[macro_export] +macro_rules! __export_slang_impl { + ($ty:ident) => ($crate::wit::slang::export!($ty with_types_in $crate::wit::slang);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::nomic::slang::parser::__export_nomic_slang_parser_1_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::nomic::slang::parser); + const _: () = { + + #[cfg(target_arch = "wasm32")] + #[link_section = "component-type:wit-bindgen:0.26.0:slang:imports and exports"] + #[doc(hidden)] + pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 14942] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe2s\x01A\x02\x01A\x02\ +\x01B\x8c\x01\x01m\xd7\x01\x0fabicoder-pragma\x13additive-expression\x0caddress-\ +type\x0eand-expression\x15arguments-declaration\x10array-expression\x0farray-typ\ +e-name\x0carray-values\x0eassembly-flags\x1aassembly-flags-declaration\x12assemb\ +ly-statement\x15assignment-expression\x16bitwise-and-expression\x15bitwise-or-ex\ +pression\x16bitwise-xor-expression\x05block\x0fbreak-statement\x0ccall-options\x17\ +call-options-expression\x0ccatch-clause\x12catch-clause-error\x0dcatch-clauses\x15\ +comparison-expression\x16conditional-expression\x13constant-definition\x15constr\ +uctor-attribute\x16constructor-attributes\x16constructor-definition\x12continue-\ +statement\x13contract-definition\x0fcontract-member\x10contract-members\x19decim\ +al-number-expression\x12do-while-statement\x0felementary-type\x0belse-branch\x0e\ +emit-statement\x0fenum-definition\x0cenum-members\x13equality-expression\x10erro\ +r-definition\x0ferror-parameter\x10error-parameters\x1cerror-parameters-declarat\ +ion\x10event-definition\x0fevent-parameter\x10event-parameters\x1cevent-paramete\ +rs-declaration\x14experimental-feature\x13experimental-pragma\x19exponentiation-\ +expression\x0aexpression\x14expression-statement\x1bfallback-function-attribute\x1c\ +fallback-function-attributes\x1cfallback-function-definition\x0dfor-statement\x17\ +for-statement-condition\x1cfor-statement-initialization\x12function-attribute\x13\ +function-attributes\x0dfunction-body\x18function-call-expression\x13function-def\ +inition\x0dfunction-name\x0dfunction-type\x17function-type-attribute\x18function\ +-type-attributes\x15hex-number-expression\x12hex-string-literal\x13hex-string-li\ +terals\x0fidentifier-path\x0cif-statement\x0cimport-alias\x0dimport-clause\x15im\ +port-deconstruction\x1cimport-deconstruction-symbol\x1dimport-deconstruction-sym\ +bols\x10import-directive\x10index-access-end\x17index-access-expression\x15inher\ +itance-specifier\x10inheritance-type\x11inheritance-types\x14interface-definitio\ +n\x11interface-members\x12library-definition\x0flibrary-members\x0bmapping-key\x10\ +mapping-key-type\x0cmapping-type\x0dmapping-value\x0dmember-access\x18member-acc\ +ess-expression\x12modifier-attribute\x13modifier-attributes\x13modifier-definiti\ +on\x13modifier-invocation\x19multiplicative-expression\x0enamed-argument\x14name\ +d-argument-group\x0fnamed-arguments\x1bnamed-arguments-declaration\x0cnamed-impo\ +rt\x0enew-expression\x0bnumber-unit\x0dor-expression\x0eoverride-paths\x1aoverri\ +de-paths-declaration\x12override-specifier\x09parameter\x0aparameters\x16paramet\ +ers-declaration\x0bpath-import\x14positional-arguments\x20positional-arguments-d\ +eclaration\x12postfix-expression\x06pragma\x10pragma-directive\x11prefix-express\ +ion\x1areceive-function-attribute\x1breceive-function-attributes\x1breceive-func\ +tion-definition\x10return-statement\x13returns-declaration\x10revert-statement\x10\ +shift-expression\x0bsource-unit\x12source-unit-member\x13source-unit-members\x18\ +state-variable-attribute\x19state-variable-attributes\x19state-variable-definiti\ +on\x1fstate-variable-definition-value\x09statement\x0astatements\x10storage-loca\ +tion\x11string-expression\x0estring-literal\x0fstring-literals\x11struct-definit\ +ion\x0dstruct-member\x0estruct-members\x0fthrow-statement\x0dtry-statement\x1ctu\ +ple-deconstruction-element\x1dtuple-deconstruction-elements\x1etuple-deconstruct\ +ion-statement\x10tuple-expression\x0ctuple-member\x0btuple-value\x0ctuple-values\ +\x0ftype-expression\x09type-name\x12typed-tuple-member\x0funchecked-block\x16uni\ +code-string-literal\x17unicode-string-literals\x1aunnamed-function-attribute\x1b\ +unnamed-function-attributes\x1bunnamed-function-definition\x14untyped-tuple-memb\ +er\"user-defined-value-type-definition\x0busing-alias\x0cusing-clause\x14using-d\ +econstruction\x1busing-deconstruction-symbol\x1cusing-deconstruction-symbols\x0f\ +using-directive\x0eusing-operator\x0cusing-target\x1evariable-declaration-statem\ +ent\x19variable-declaration-type\x1avariable-declaration-value\x12version-compar\ +ator\x12version-expression\x16version-expression-set\x17version-expression-sets\x0e\ +version-pragma\x0dversion-range\x12version-specifiers\x0fwhile-statement\x0dyul-\ +arguments\x17yul-assignment-operator\x09yul-block\x13yul-break-statement\x15yul-\ +built-in-function\x0fyul-colon-equal\x16yul-continue-statement\x10yul-default-ca\ +se\x0eyul-expression\x11yul-for-statement\x1cyul-function-call-expression\x17yul\ +-function-definition\x10yul-if-statement\x09yul-label\x13yul-leave-statement\x0b\ +yul-literal\x0eyul-parameters\x1ayul-parameters-declaration\x08yul-path\x12yul-p\ +ath-component\x09yul-paths\x14yul-return-variables\x17yul-returns-declaration\x1e\ +yul-stack-assignment-statement\x0dyul-statement\x0eyul-statements\x0fyul-switch-\ +case\x10yul-switch-cases\x14yul-switch-statement\x0eyul-value-case!yul-variable-\ +assignment-statement\"yul-variable-declaration-statement\x1eyul-variable-declara\ +tion-value\x04\0\x10nonterminal-kind\x03\0\0\x01m\x83\x01\x04item\x07variant\x09\ +separator\x07operand\x0cleft-operand\x0dright-operand\x0eleading-trivia\x0ftrail\ +ing-trivia\x10abicoder-keyword\x10abstract-keyword\x0faddress-keyword\x05alias\x11\ +anonymous-keyword\x09arguments\x0aas-keyword\x10assembly-keyword\x0aassignment\x08\ +asterisk\x0aattributes\x05block\x04body\x0dbreak-keyword\x0ccase-keyword\x05case\ +s\x0dcatch-clauses\x0dcatch-keyword\x06clause\x0bclose-brace\x0dclose-bracket\x0b\ +close-paren\x05colon\x09condition\x10constant-keyword\x13constructor-keyword\x10\ +continue-keyword\x10contract-keyword\x0fdefault-keyword\x0ado-keyword\x08element\ +s\x0belse-branch\x0celse-keyword\x0cemit-keyword\x03end\x0cenum-keyword\x05equal\ +\x12equal-greater-than\x05error\x0derror-keyword\x05event\x0devent-keyword\x14ex\ +perimental-keyword\x0aexpression\x10fallback-keyword\x10false-expression\x07feat\ +ure\x05flags\x0bfor-keyword\x0cfrom-keyword\x10function-keyword\x0eglobal-keywor\ +d\x0aidentifier\x0aif-keyword\x0eimport-keyword\x05index\x0findexed-keyword\x0bi\ +nheritance\x0einitialization\x11interface-keyword\x0ais-keyword\x05items\x08iter\ +ator\x08key-type\x05label\x0dleave-keyword\x0blet-keyword\x0flibrary-keyword\x07\ +literal\x0fmapping-keyword\x06member\x07members\x12minus-greater-than\x10modifie\ +r-keyword\x04name\x05names\x0bnew-keyword\x0aopen-brace\x0copen-bracket\x0aopen-\ +paren\x08operator\x07options\x0aoverridden\x10override-keyword\x0aparameters\x04\ +path\x05paths\x0fpayable-keyword\x06period\x06pragma\x0epragma-keyword\x0dquesti\ +on-mark\x0freceive-keyword\x0ereturn-keyword\x07returns\x0freturns-keyword\x0ere\ +vert-keyword\x09semicolon\x04sets\x10solidity-keyword\x05start\x0astatements\x10\ +storage-location\x0estruct-keyword\x0eswitch-keyword\x07symbols\x06target\x0dthr\ +ow-keyword\x0ftrue-expression\x0btry-keyword\x0ctype-keyword\x09type-name\x05typ\ +es\x11unchecked-keyword\x04unit\x0dusing-keyword\x05value\x0avalue-type\x0bvar-k\ +eyword\x0dvariable-type\x09variables\x07version\x0dwhile-keyword\x04\0\x0aedge-l\ +abel\x03\0\x02\x01m\xf0\x02\x07skipped\x10abicoder-keyword\x10abstract-keyword\x0f\ +address-keyword\x0dafter-keyword\x0dalias-keyword\x09ampersand\x13ampersand-ampe\ +rsand\x0fampersand-equal\x11anonymous-keyword\x0dapply-keyword\x0aas-keyword\x10\ +assembly-keyword\x08asterisk\x11asterisk-asterisk\x0easterisk-equal\x0cauto-keyw\ +ord\x04bang\x0abang-equal\x03bar\x07bar-bar\x09bar-equal\x0cbool-keyword\x0dbrea\ +k-keyword\x0cbyte-keyword\x0dbytes-keyword\x11call-data-keyword\x05caret\x0bcare\ +t-equal\x0ccase-keyword\x0dcatch-keyword\x0bclose-brace\x0dclose-bracket\x0bclos\ +e-paren\x05colon\x0bcolon-equal\x05comma\x10constant-keyword\x13constructor-keyw\ +ord\x10continue-keyword\x10contract-keyword\x0fcopy-of-keyword\x0cdays-keyword\x0f\ +decimal-literal\x0fdefault-keyword\x0edefine-keyword\x0edelete-keyword\x0ado-key\ +word\x20double-quoted-hex-string-literal\x1cdouble-quoted-string-literal$double-\ +quoted-unicode-string-literal\x1ddouble-quoted-version-literal\x0celse-keyword\x0c\ +emit-keyword\x0bend-of-line\x0cenum-keyword\x05equal\x0bequal-equal\x12equal-gre\ +ater-than\x0derror-keyword\x0dether-keyword\x0devent-keyword\x14experimental-key\ +word\x10external-keyword\x10fallback-keyword\x0dfalse-keyword\x0dfinal-keyword\x0e\ +finney-keyword\x0dfixed-keyword\x0bfor-keyword\x0cfrom-keyword\x10function-keywo\ +rd\x0eglobal-keyword\x0cgreater-than\x12greater-than-equal\x19greater-than-great\ +er-than\x1fgreater-than-greater-than-equal&greater-than-greater-than-greater-tha\ +n,greater-than-greater-than-greater-than-equal\x0cgwei-keyword\x0bhex-keyword\x0b\ +hex-literal\x0dhours-keyword\x0aidentifier\x0aif-keyword\x11immutable-keyword\x12\ +implements-keyword\x0eimport-keyword\x0ain-keyword\x0findexed-keyword\x0einline-\ +keyword\x0bint-keyword\x11interface-keyword\x10internal-keyword\x0ais-keyword\x09\ +less-than\x0fless-than-equal\x13less-than-less-than\x19less-than-less-than-equal\ +\x0blet-keyword\x0flibrary-keyword\x0dmacro-keyword\x0fmapping-keyword\x0dmatch-\ +keyword\x0ememory-keyword\x05minus\x0bminus-equal\x12minus-greater-than\x0bminus\ +-minus\x0fminutes-keyword\x10modifier-keyword\x12multi-line-comment\x1bmulti-lin\ +e-nat-spec-comment\x0fmutable-keyword\x0bnew-keyword\x0cnull-keyword\x0aof-keywo\ +rd\x0aopen-brace\x0copen-bracket\x0aopen-paren\x10override-keyword\x0fpartial-ke\ +yword\x0fpayable-keyword\x07percent\x0dpercent-equal\x06period\x04plus\x0aplus-e\ +qual\x09plus-plus\x0epragma-keyword\x0fprivate-keyword\x0fpromise-keyword\x0epub\ +lic-keyword\x0cpure-keyword\x0dquestion-mark\x0freceive-keyword\x11reference-key\ +word\x13relocatable-keyword\x0ereturn-keyword\x0freturns-keyword\x0erevert-keywo\ +rd\x0esealed-keyword\x0fseconds-keyword\x09semicolon\x13single-line-comment\x1cs\ +ingle-line-nat-spec-comment\x20single-quoted-hex-string-literal\x1csingle-quoted\ +-string-literal$single-quoted-unicode-string-literal\x1dsingle-quoted-version-li\ +teral\x0fsize-of-keyword\x05slash\x0bslash-equal\x10solidity-keyword\x0estatic-k\ +eyword\x0fstorage-keyword\x0estring-keyword\x0estruct-keyword\x10supports-keywor\ +d\x0eswitch-keyword\x0dszabo-keyword\x0dthrow-keyword\x05tilde\x0ctrue-keyword\x0b\ +try-keyword\x10type-def-keyword\x0ctype-keyword\x0ftype-of-keyword\x0eufixed-key\ +word\x0cuint-keyword\x11unchecked-keyword\x0dusing-keyword\x0bvar-keyword\x11ver\ +sion-specifier\x0cview-keyword\x0fvirtual-keyword\x0dweeks-keyword\x0bwei-keywor\ +d\x0dwhile-keyword\x0awhitespace\x0dyears-keyword\x14yul-abstract-keyword\x0fyul\ +-add-keyword\x13yul-add-mod-keyword\x13yul-address-keyword\x11yul-after-keyword\x11\ +yul-alias-keyword\x0fyul-and-keyword\x15yul-anonymous-keyword\x11yul-apply-keywo\ +rd\x0eyul-as-keyword\x14yul-assembly-keyword\x10yul-auto-keyword\x13yul-balance-\ +keyword\x14yul-base-fee-keyword\x19yul-blob-base-fee-keyword\x15yul-blob-hash-ke\ +yword\x16yul-block-hash-keyword\x10yul-bool-keyword\x11yul-break-keyword\x10yul-\ +byte-keyword\x11yul-bytes-keyword\x15yul-call-code-keyword\x1ayul-call-data-copy\ +-keyword\x15yul-call-data-keyword\x1ayul-call-data-load-keyword\x1ayul-call-data\ +-size-keyword\x10yul-call-keyword\x16yul-call-value-keyword\x12yul-caller-keywor\ +d\x10yul-case-keyword\x11yul-catch-keyword\x14yul-chain-id-keyword\x15yul-coin-b\ +ase-keyword\x14yul-constant-keyword\x17yul-constructor-keyword\x14yul-continue-k\ +eyword\x14yul-contract-keyword\x13yul-copy-of-keyword\x13yul-create2-keyword\x12\ +yul-create-keyword\x10yul-days-keyword\x13yul-decimal-literal\x13yul-default-key\ +word\x12yul-define-keyword\x19yul-delegate-call-keyword\x12yul-delete-keyword\x16\ +yul-difficulty-keyword\x0fyul-div-keyword\x0eyul-do-keyword\x10yul-else-keyword\x10\ +yul-emit-keyword\x10yul-enum-keyword\x0eyul-eq-keyword\x11yul-ether-keyword\x11y\ +ul-event-keyword\x0fyul-exp-keyword\x19yul-ext-code-copy-keyword\x19yul-ext-code\ +-hash-keyword\x19yul-ext-code-size-keyword\x14yul-external-keyword\x14yul-fallba\ +ck-keyword\x11yul-false-keyword\x11yul-final-keyword\x12yul-finney-keyword\x11yu\ +l-fixed-keyword\x0fyul-for-keyword\x14yul-function-keyword\x0fyul-gas-keyword\x15\ +yul-gas-limit-keyword\x15yul-gas-price-keyword\x0eyul-gt-keyword\x10yul-gwei-key\ +word\x0fyul-hex-keyword\x0fyul-hex-literal\x11yul-hours-keyword\x0eyul-identifie\ +r\x0eyul-if-keyword\x15yul-immutable-keyword\x16yul-implements-keyword\x12yul-im\ +port-keyword\x0eyul-in-keyword\x13yul-indexed-keyword\x12yul-inline-keyword\x0fy\ +ul-int-keyword\x15yul-interface-keyword\x14yul-internal-keyword\x13yul-invalid-k\ +eyword\x0eyul-is-keyword\x13yul-is-zero-keyword\x15yul-keccak256-keyword\x11yul-\ +leave-keyword\x0fyul-let-keyword\x13yul-library-keyword\x10yul-log0-keyword\x10y\ +ul-log1-keyword\x10yul-log2-keyword\x10yul-log3-keyword\x10yul-log4-keyword\x0ey\ +ul-lt-keyword\x11yul-mcopy-keyword\x11yul-mload-keyword\x11yul-msize-keyword\x13\ +yul-mstore8-keyword\x12yul-mstore-keyword\x11yul-macro-keyword\x13yul-mapping-ke\ +yword\x11yul-match-keyword\x12yul-memory-keyword\x13yul-minutes-keyword\x0fyul-m\ +od-keyword\x14yul-modifier-keyword\x0fyul-mul-keyword\x13yul-mul-mod-keyword\x13\ +yul-mutable-keyword\x0fyul-new-keyword\x0fyul-not-keyword\x10yul-null-keyword\x12\ +yul-number-keyword\x0eyul-of-keyword\x0eyul-or-keyword\x12yul-origin-keyword\x14\ +yul-override-keyword\x13yul-partial-keyword\x13yul-payable-keyword\x0fyul-pop-ke\ +yword\x12yul-pragma-keyword\x17yul-prev-randao-keyword\x13yul-private-keyword\x13\ +yul-promise-keyword\x12yul-public-keyword\x10yul-pure-keyword\x13yul-receive-key\ +word\x15yul-reference-keyword\x17yul-relocatable-keyword\x1cyul-return-data-copy\ +-keyword\x1cyul-return-data-size-keyword\x12yul-return-keyword\x13yul-returns-ke\ +yword\x12yul-revert-keyword\x10yul-sdiv-keyword\x11yul-sload-keyword\x10yul-smod\ +-keyword\x12yul-sstore-keyword\x0fyul-sar-keyword\x12yul-sealed-keyword\x13yul-s\ +econds-keyword\x18yul-self-balance-keyword\x19yul-self-destruct-keyword\x0fyul-s\ +gt-keyword\x10yul-sha3-keyword\x0fyul-shl-keyword\x0fyul-shr-keyword\x17yul-sign\ +-extend-keyword\x13yul-size-of-keyword\x0fyul-slt-keyword\x17yul-static-call-key\ +word\x12yul-static-keyword\x10yul-stop-keyword\x13yul-storage-keyword\x12yul-str\ +ing-keyword\x12yul-struct-keyword\x0fyul-sub-keyword\x13yul-suicide-keyword\x14y\ +ul-supports-keyword\x12yul-switch-keyword\x11yul-szabo-keyword\x11yul-tload-keyw\ +ord\x12yul-tstore-keyword\x11yul-throw-keyword\x15yul-timestamp-keyword\x10yul-t\ +rue-keyword\x0fyul-try-keyword\x14yul-type-def-keyword\x10yul-type-keyword\x13yu\ +l-type-of-keyword\x12yul-ufixed-keyword\x10yul-uint-keyword\x15yul-unchecked-key\ +word\x11yul-using-keyword\x0fyul-var-keyword\x10yul-view-keyword\x13yul-virtual-\ +keyword\x11yul-weeks-keyword\x0fyul-wei-keyword\x11yul-while-keyword\x0fyul-xor-\ +keyword\x11yul-years-keyword\x04\0\x0dterminal-kind\x03\0\x04\x04\0\x08language\x03\ +\x01\x04\0\x0bparse-error\x03\x01\x04\0\x0cparse-output\x03\x01\x04\0\x10nonterm\ +inal-node\x03\x01\x04\0\x0dterminal-node\x03\x01\x01i\x09\x01i\x0a\x01q\x02\x0bn\ +onterminal\x01\x0b\0\x08terminal\x01\x0c\0\x04\0\x04node\x03\0\x0d\x04\0\x06curs\ +or\x03\x01\x04\0\x05query\x03\x01\x01r\x03\x07messages\x04liney\x06columny\x04\0\ +\x0bquery-error\x03\0\x11\x01i\x0f\x01p\x13\x01o\x02s\x14\x01p\x15\x01r\x02\x0cq\ +uery-numbery\x08captures\x16\x04\0\x0bquery-match\x03\0\x17\x04\0\x14query-match\ +-iterator\x03\x01\x01m\x04\x05error\x07warning\x0binformation\x04hint\x04\0\x08s\ +everity\x03\0\x1a\x01r\x04\x04utf8y\x05utf16y\x04liney\x06columny\x04\0\x0atext-\ +index\x03\0\x1c\x01r\x02\x05start\x1d\x03end\x1d\x04\0\x0atext-range\x03\0\x1e\x01\ +ps\x01@\0\0\x20\x04\0#[static]language.supported-versions\x01!\x01i\x06\x01j\x01\ +\"\x01s\x01@\x01\x07versions\0#\x04\0\x14[static]language.new\x01$\x01h\x06\x01@\ +\x01\x04self%\0s\x04\0\x18[method]language.version\x01&\x01i\x08\x01@\x03\x04sel\ +f%\x04kind\x01\x05inputs\0'\x04\0\x16[method]language.parse\x01(\x01h\x07\x01@\x01\ +\x04self)\0\x1b\x04\0\x1c[method]parse-error.severity\x01*\x01@\x01\x04self)\0\x1f\ +\x04\0\x1e[method]parse-error.text-range\x01+\x01@\x01\x04self)\0s\x04\0\x1b[met\ +hod]parse-error.message\x01,\x01h\x08\x01@\x01\x04self-\0\x0e\x04\0\x19[method]p\ +arse-output.tree\x01.\x01i\x07\x01p/\x01@\x01\x04self-\00\x04\0\x1b[method]parse\ +-output.errors\x011\x01@\x01\x04self-\0\x7f\x04\0\x1d[method]parse-output.is-val\ +id\x012\x01@\x01\x04self-\0\x13\x04\0'[method]parse-output.create-tree-cursor\x01\ +3\x01h\x09\x01@\x01\x04self4\0\x01\x04\0\x1d[method]nonterminal-node.kind\x015\x01\ +@\x01\x04self4\0\x1d\x04\0![method]nonterminal-node.text-len\x016\x01p\x0e\x01@\x01\ +\x04self4\07\x04\0![method]nonterminal-node.children\x018\x01@\x02\x04self4\x0bt\ +ext-offset\x1d\0\x13\x04\0&[method]nonterminal-node.create-cursor\x019\x01@\x01\x04\ +self4\0s\x04\0\x20[method]nonterminal-node.unparse\x01:\x01h\x0a\x01@\x01\x04sel\ +f;\0\x05\x04\0\x1a[method]terminal-node.kind\x01<\x01@\x01\x04self;\0\x1d\x04\0\x1e\ +[method]terminal-node.text-len\x01=\x01@\x01\x04self;\0s\x04\0\x1a[method]termin\ +al-node.text\x01>\x01h\x0f\x01@\x01\x04self?\x01\0\x04\0\x14[method]cursor.reset\ +\x01@\x04\0\x17[method]cursor.complete\x01@\x01@\x01\x04self?\0\x7f\x04\0\x1b[me\ +thod]cursor.is-completed\x01A\x01@\x01\x04self?\0\x13\x04\0\x14[method]cursor.cl\ +one\x01B\x04\0\x14[method]cursor.spawn\x01B\x01@\x01\x04self?\0\x0e\x04\0\x13[me\ +thod]cursor.node\x01C\x01k\x03\x01@\x01\x04self?\0\xc4\0\x04\0\x14[method]cursor\ +.label\x01E\x01@\x01\x04self?\0\x1d\x04\0\x1a[method]cursor.text-offset\x01F\x01\ +@\x01\x04self?\0\x1f\x04\0\x19[method]cursor.text-range\x01G\x01@\x01\x04self?\0\ +y\x04\0\x14[method]cursor.depth\x01H\x01p\x0b\x01@\x01\x04self?\0\xc9\0\x04\0\x18\ +[method]cursor.ancestors\x01J\x04\0\x19[method]cursor.go-to-next\x01A\x04\0([met\ +hod]cursor.go-to-next-non-descendent\x01A\x04\0\x1d[method]cursor.go-to-previous\ +\x01A\x04\0\x1b[method]cursor.go-to-parent\x01A\x04\0\x20[method]cursor.go-to-fi\ +rst-child\x01A\x04\0\x1f[method]cursor.go-to-last-child\x01A\x01@\x02\x04self?\x0c\ +child-numbery\0\x7f\x04\0\x1e[method]cursor.go-to-nth-child\x01K\x04\0![method]c\ +ursor.go-to-next-sibling\x01A\x04\0%[method]cursor.go-to-previous-sibling\x01A\x04\ +\0\"[method]cursor.go-to-next-terminal\x01A\x01@\x02\x04self?\x04kind\x05\0\x7f\x04\ +\0,[method]cursor.go-to-next-terminal-with-kind\x01L\x01p\x05\x01@\x02\x04self?\x05\ +kinds\xcd\0\0\x7f\x04\0-[method]cursor.go-to-next-terminal-with-kinds\x01N\x04\0\ +%[method]cursor.go-to-next-nonterminal\x01A\x01@\x02\x04self?\x04kind\x01\0\x7f\x04\ +\0/[method]cursor.go-to-next-nonterminal-with-kind\x01O\x01p\x01\x01@\x02\x04sel\ +f?\x05kinds\xd0\0\0\x7f\x04\00[method]cursor.go-to-next-nonterminal-with-kinds\x01\ +Q\x01h\x10\x01p\xd2\0\x01i\x19\x01@\x02\x04self?\x07queries\xd3\0\0\xd4\0\x04\0\x14\ +[method]cursor.query\x01U\x01i\x10\x01j\x01\xd6\0\x01\x12\x01@\x01\x04texts\0\xd7\ +\0\x04\0\x13[static]query.parse\x01X\x01h\x19\x01k\x18\x01@\x01\x04self\xd9\0\0\xda\ +\0\x04\0![method]query-match-iterator.next\x01[\x04\x01\x18nomic:slang/parser@1.\ +0.0\x05\0\x04\x01\x17nomic:slang/slang@1.0.0\x04\0\x0b\x0b\x01\0\x05slang\x03\0\0\ +\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.209.1\x10wit-bind\ +gen-rust\x060.26.0"; + }; + ) +} +#[doc(inline)] +pub use __export_slang_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.26.0:slang-with-all-of-its-exports-removed:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 221] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07B\x01A\x02\x01A\0\x04\ +\x017nomic:slang/slang-with-all-of-its-exports-removed@1.0.0\x04\0\x0b+\x01\0%sl\ +ang-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.209.1\x10wit-bindgen-rust\x060.26.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen::rt::maybe_link_cabi_realloc(); +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.wit b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.wit new file mode 100644 index 0000000000..0a25176798 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/generated/slang.wit @@ -0,0 +1,860 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +package nomic:slang@1.0.0; + +world slang { + export parser; +} + +interface parser { + + enum nonterminal-kind { + %abicoder-pragma, + %additive-expression, + %address-type, + %and-expression, + %arguments-declaration, + %array-expression, + %array-type-name, + %array-values, + %assembly-flags, + %assembly-flags-declaration, + %assembly-statement, + %assignment-expression, + %bitwise-and-expression, + %bitwise-or-expression, + %bitwise-xor-expression, + %block, + %break-statement, + %call-options, + %call-options-expression, + %catch-clause, + %catch-clause-error, + %catch-clauses, + %comparison-expression, + %conditional-expression, + %constant-definition, + %constructor-attribute, + %constructor-attributes, + %constructor-definition, + %continue-statement, + %contract-definition, + %contract-member, + %contract-members, + %decimal-number-expression, + %do-while-statement, + %elementary-type, + %else-branch, + %emit-statement, + %enum-definition, + %enum-members, + %equality-expression, + %error-definition, + %error-parameter, + %error-parameters, + %error-parameters-declaration, + %event-definition, + %event-parameter, + %event-parameters, + %event-parameters-declaration, + %experimental-feature, + %experimental-pragma, + %exponentiation-expression, + %expression, + %expression-statement, + %fallback-function-attribute, + %fallback-function-attributes, + %fallback-function-definition, + %for-statement, + %for-statement-condition, + %for-statement-initialization, + %function-attribute, + %function-attributes, + %function-body, + %function-call-expression, + %function-definition, + %function-name, + %function-type, + %function-type-attribute, + %function-type-attributes, + %hex-number-expression, + %hex-string-literal, + %hex-string-literals, + %identifier-path, + %if-statement, + %import-alias, + %import-clause, + %import-deconstruction, + %import-deconstruction-symbol, + %import-deconstruction-symbols, + %import-directive, + %index-access-end, + %index-access-expression, + %inheritance-specifier, + %inheritance-type, + %inheritance-types, + %interface-definition, + %interface-members, + %library-definition, + %library-members, + %mapping-key, + %mapping-key-type, + %mapping-type, + %mapping-value, + %member-access, + %member-access-expression, + %modifier-attribute, + %modifier-attributes, + %modifier-definition, + %modifier-invocation, + %multiplicative-expression, + %named-argument, + %named-argument-group, + %named-arguments, + %named-arguments-declaration, + %named-import, + %new-expression, + %number-unit, + %or-expression, + %override-paths, + %override-paths-declaration, + %override-specifier, + %parameter, + %parameters, + %parameters-declaration, + %path-import, + %positional-arguments, + %positional-arguments-declaration, + %postfix-expression, + %pragma, + %pragma-directive, + %prefix-expression, + %receive-function-attribute, + %receive-function-attributes, + %receive-function-definition, + %return-statement, + %returns-declaration, + %revert-statement, + %shift-expression, + %source-unit, + %source-unit-member, + %source-unit-members, + %state-variable-attribute, + %state-variable-attributes, + %state-variable-definition, + %state-variable-definition-value, + %statement, + %statements, + %storage-location, + %string-expression, + %string-literal, + %string-literals, + %struct-definition, + %struct-member, + %struct-members, + %throw-statement, + %try-statement, + %tuple-deconstruction-element, + %tuple-deconstruction-elements, + %tuple-deconstruction-statement, + %tuple-expression, + %tuple-member, + %tuple-value, + %tuple-values, + %type-expression, + %type-name, + %typed-tuple-member, + %unchecked-block, + %unicode-string-literal, + %unicode-string-literals, + %unnamed-function-attribute, + %unnamed-function-attributes, + %unnamed-function-definition, + %untyped-tuple-member, + %user-defined-value-type-definition, + %using-alias, + %using-clause, + %using-deconstruction, + %using-deconstruction-symbol, + %using-deconstruction-symbols, + %using-directive, + %using-operator, + %using-target, + %variable-declaration-statement, + %variable-declaration-type, + %variable-declaration-value, + %version-comparator, + %version-expression, + %version-expression-set, + %version-expression-sets, + %version-pragma, + %version-range, + %version-specifiers, + %while-statement, + %yul-arguments, + %yul-assignment-operator, + %yul-block, + %yul-break-statement, + %yul-built-in-function, + %yul-colon-equal, + %yul-continue-statement, + %yul-default-case, + %yul-expression, + %yul-for-statement, + %yul-function-call-expression, + %yul-function-definition, + %yul-if-statement, + %yul-label, + %yul-leave-statement, + %yul-literal, + %yul-parameters, + %yul-parameters-declaration, + %yul-path, + %yul-path-component, + %yul-paths, + %yul-return-variables, + %yul-returns-declaration, + %yul-stack-assignment-statement, + %yul-statement, + %yul-statements, + %yul-switch-case, + %yul-switch-cases, + %yul-switch-statement, + %yul-value-case, + %yul-variable-assignment-statement, + %yul-variable-declaration-statement, + %yul-variable-declaration-value, + } + + enum edge-label { + // Built-in: + %item, + %variant, + %separator, + %operand, + %left-operand, + %right-operand, + %leading-trivia, + %trailing-trivia, + + // Generated: + %abicoder-keyword, + %abstract-keyword, + %address-keyword, + %alias, + %anonymous-keyword, + %arguments, + %as-keyword, + %assembly-keyword, + %assignment, + %asterisk, + %attributes, + %block, + %body, + %break-keyword, + %case-keyword, + %cases, + %catch-clauses, + %catch-keyword, + %clause, + %close-brace, + %close-bracket, + %close-paren, + %colon, + %condition, + %constant-keyword, + %constructor-keyword, + %continue-keyword, + %contract-keyword, + %default-keyword, + %do-keyword, + %elements, + %else-branch, + %else-keyword, + %emit-keyword, + %end, + %enum-keyword, + %equal, + %equal-greater-than, + %error, + %error-keyword, + %event, + %event-keyword, + %experimental-keyword, + %expression, + %fallback-keyword, + %false-expression, + %feature, + %flags, + %for-keyword, + %from-keyword, + %function-keyword, + %global-keyword, + %identifier, + %if-keyword, + %import-keyword, + %index, + %indexed-keyword, + %inheritance, + %initialization, + %interface-keyword, + %is-keyword, + %items, + %iterator, + %key-type, + %label, + %leave-keyword, + %let-keyword, + %library-keyword, + %literal, + %mapping-keyword, + %member, + %members, + %minus-greater-than, + %modifier-keyword, + %name, + %names, + %new-keyword, + %open-brace, + %open-bracket, + %open-paren, + %operator, + %options, + %overridden, + %override-keyword, + %parameters, + %path, + %paths, + %payable-keyword, + %period, + %pragma, + %pragma-keyword, + %question-mark, + %receive-keyword, + %return-keyword, + %returns, + %returns-keyword, + %revert-keyword, + %semicolon, + %sets, + %solidity-keyword, + %start, + %statements, + %storage-location, + %struct-keyword, + %switch-keyword, + %symbols, + %target, + %throw-keyword, + %true-expression, + %try-keyword, + %type-keyword, + %type-name, + %types, + %unchecked-keyword, + %unit, + %using-keyword, + %value, + %value-type, + %var-keyword, + %variable-type, + %variables, + %version, + %while-keyword, + } + + enum terminal-kind { + // Built-in: + skipped, + + // Generated: + %abicoder-keyword, + %abstract-keyword, + %address-keyword, + %after-keyword, + %alias-keyword, + %ampersand, + %ampersand-ampersand, + %ampersand-equal, + %anonymous-keyword, + %apply-keyword, + %as-keyword, + %assembly-keyword, + %asterisk, + %asterisk-asterisk, + %asterisk-equal, + %auto-keyword, + %bang, + %bang-equal, + %bar, + %bar-bar, + %bar-equal, + %bool-keyword, + %break-keyword, + %byte-keyword, + %bytes-keyword, + %call-data-keyword, + %caret, + %caret-equal, + %case-keyword, + %catch-keyword, + %close-brace, + %close-bracket, + %close-paren, + %colon, + %colon-equal, + %comma, + %constant-keyword, + %constructor-keyword, + %continue-keyword, + %contract-keyword, + %copy-of-keyword, + %days-keyword, + %decimal-literal, + %default-keyword, + %define-keyword, + %delete-keyword, + %do-keyword, + %double-quoted-hex-string-literal, + %double-quoted-string-literal, + %double-quoted-unicode-string-literal, + %double-quoted-version-literal, + %else-keyword, + %emit-keyword, + %end-of-line, + %enum-keyword, + %equal, + %equal-equal, + %equal-greater-than, + %error-keyword, + %ether-keyword, + %event-keyword, + %experimental-keyword, + %external-keyword, + %fallback-keyword, + %false-keyword, + %final-keyword, + %finney-keyword, + %fixed-keyword, + %for-keyword, + %from-keyword, + %function-keyword, + %global-keyword, + %greater-than, + %greater-than-equal, + %greater-than-greater-than, + %greater-than-greater-than-equal, + %greater-than-greater-than-greater-than, + %greater-than-greater-than-greater-than-equal, + %gwei-keyword, + %hex-keyword, + %hex-literal, + %hours-keyword, + %identifier, + %if-keyword, + %immutable-keyword, + %implements-keyword, + %import-keyword, + %in-keyword, + %indexed-keyword, + %inline-keyword, + %int-keyword, + %interface-keyword, + %internal-keyword, + %is-keyword, + %less-than, + %less-than-equal, + %less-than-less-than, + %less-than-less-than-equal, + %let-keyword, + %library-keyword, + %macro-keyword, + %mapping-keyword, + %match-keyword, + %memory-keyword, + %minus, + %minus-equal, + %minus-greater-than, + %minus-minus, + %minutes-keyword, + %modifier-keyword, + %multi-line-comment, + %multi-line-nat-spec-comment, + %mutable-keyword, + %new-keyword, + %null-keyword, + %of-keyword, + %open-brace, + %open-bracket, + %open-paren, + %override-keyword, + %partial-keyword, + %payable-keyword, + %percent, + %percent-equal, + %period, + %plus, + %plus-equal, + %plus-plus, + %pragma-keyword, + %private-keyword, + %promise-keyword, + %public-keyword, + %pure-keyword, + %question-mark, + %receive-keyword, + %reference-keyword, + %relocatable-keyword, + %return-keyword, + %returns-keyword, + %revert-keyword, + %sealed-keyword, + %seconds-keyword, + %semicolon, + %single-line-comment, + %single-line-nat-spec-comment, + %single-quoted-hex-string-literal, + %single-quoted-string-literal, + %single-quoted-unicode-string-literal, + %single-quoted-version-literal, + %size-of-keyword, + %slash, + %slash-equal, + %solidity-keyword, + %static-keyword, + %storage-keyword, + %string-keyword, + %struct-keyword, + %supports-keyword, + %switch-keyword, + %szabo-keyword, + %throw-keyword, + %tilde, + %true-keyword, + %try-keyword, + %type-def-keyword, + %type-keyword, + %type-of-keyword, + %ufixed-keyword, + %uint-keyword, + %unchecked-keyword, + %using-keyword, + %var-keyword, + %version-specifier, + %view-keyword, + %virtual-keyword, + %weeks-keyword, + %wei-keyword, + %while-keyword, + %whitespace, + %years-keyword, + %yul-abstract-keyword, + %yul-add-keyword, + %yul-add-mod-keyword, + %yul-address-keyword, + %yul-after-keyword, + %yul-alias-keyword, + %yul-and-keyword, + %yul-anonymous-keyword, + %yul-apply-keyword, + %yul-as-keyword, + %yul-assembly-keyword, + %yul-auto-keyword, + %yul-balance-keyword, + %yul-base-fee-keyword, + %yul-blob-base-fee-keyword, + %yul-blob-hash-keyword, + %yul-block-hash-keyword, + %yul-bool-keyword, + %yul-break-keyword, + %yul-byte-keyword, + %yul-bytes-keyword, + %yul-call-code-keyword, + %yul-call-data-copy-keyword, + %yul-call-data-keyword, + %yul-call-data-load-keyword, + %yul-call-data-size-keyword, + %yul-call-keyword, + %yul-call-value-keyword, + %yul-caller-keyword, + %yul-case-keyword, + %yul-catch-keyword, + %yul-chain-id-keyword, + %yul-coin-base-keyword, + %yul-constant-keyword, + %yul-constructor-keyword, + %yul-continue-keyword, + %yul-contract-keyword, + %yul-copy-of-keyword, + %yul-create2-keyword, + %yul-create-keyword, + %yul-days-keyword, + %yul-decimal-literal, + %yul-default-keyword, + %yul-define-keyword, + %yul-delegate-call-keyword, + %yul-delete-keyword, + %yul-difficulty-keyword, + %yul-div-keyword, + %yul-do-keyword, + %yul-else-keyword, + %yul-emit-keyword, + %yul-enum-keyword, + %yul-eq-keyword, + %yul-ether-keyword, + %yul-event-keyword, + %yul-exp-keyword, + %yul-ext-code-copy-keyword, + %yul-ext-code-hash-keyword, + %yul-ext-code-size-keyword, + %yul-external-keyword, + %yul-fallback-keyword, + %yul-false-keyword, + %yul-final-keyword, + %yul-finney-keyword, + %yul-fixed-keyword, + %yul-for-keyword, + %yul-function-keyword, + %yul-gas-keyword, + %yul-gas-limit-keyword, + %yul-gas-price-keyword, + %yul-gt-keyword, + %yul-gwei-keyword, + %yul-hex-keyword, + %yul-hex-literal, + %yul-hours-keyword, + %yul-identifier, + %yul-if-keyword, + %yul-immutable-keyword, + %yul-implements-keyword, + %yul-import-keyword, + %yul-in-keyword, + %yul-indexed-keyword, + %yul-inline-keyword, + %yul-int-keyword, + %yul-interface-keyword, + %yul-internal-keyword, + %yul-invalid-keyword, + %yul-is-keyword, + %yul-is-zero-keyword, + %yul-keccak256-keyword, + %yul-leave-keyword, + %yul-let-keyword, + %yul-library-keyword, + %yul-log0-keyword, + %yul-log1-keyword, + %yul-log2-keyword, + %yul-log3-keyword, + %yul-log4-keyword, + %yul-lt-keyword, + %yul-mcopy-keyword, + %yul-mload-keyword, + %yul-msize-keyword, + %yul-mstore8-keyword, + %yul-mstore-keyword, + %yul-macro-keyword, + %yul-mapping-keyword, + %yul-match-keyword, + %yul-memory-keyword, + %yul-minutes-keyword, + %yul-mod-keyword, + %yul-modifier-keyword, + %yul-mul-keyword, + %yul-mul-mod-keyword, + %yul-mutable-keyword, + %yul-new-keyword, + %yul-not-keyword, + %yul-null-keyword, + %yul-number-keyword, + %yul-of-keyword, + %yul-or-keyword, + %yul-origin-keyword, + %yul-override-keyword, + %yul-partial-keyword, + %yul-payable-keyword, + %yul-pop-keyword, + %yul-pragma-keyword, + %yul-prev-randao-keyword, + %yul-private-keyword, + %yul-promise-keyword, + %yul-public-keyword, + %yul-pure-keyword, + %yul-receive-keyword, + %yul-reference-keyword, + %yul-relocatable-keyword, + %yul-return-data-copy-keyword, + %yul-return-data-size-keyword, + %yul-return-keyword, + %yul-returns-keyword, + %yul-revert-keyword, + %yul-sdiv-keyword, + %yul-sload-keyword, + %yul-smod-keyword, + %yul-sstore-keyword, + %yul-sar-keyword, + %yul-sealed-keyword, + %yul-seconds-keyword, + %yul-self-balance-keyword, + %yul-self-destruct-keyword, + %yul-sgt-keyword, + %yul-sha3-keyword, + %yul-shl-keyword, + %yul-shr-keyword, + %yul-sign-extend-keyword, + %yul-size-of-keyword, + %yul-slt-keyword, + %yul-static-call-keyword, + %yul-static-keyword, + %yul-stop-keyword, + %yul-storage-keyword, + %yul-string-keyword, + %yul-struct-keyword, + %yul-sub-keyword, + %yul-suicide-keyword, + %yul-supports-keyword, + %yul-switch-keyword, + %yul-szabo-keyword, + %yul-tload-keyword, + %yul-tstore-keyword, + %yul-throw-keyword, + %yul-timestamp-keyword, + %yul-true-keyword, + %yul-try-keyword, + %yul-type-def-keyword, + %yul-type-keyword, + %yul-type-of-keyword, + %yul-ufixed-keyword, + %yul-uint-keyword, + %yul-unchecked-keyword, + %yul-using-keyword, + %yul-var-keyword, + %yul-view-keyword, + %yul-virtual-keyword, + %yul-weeks-keyword, + %yul-wei-keyword, + %yul-while-keyword, + %yul-xor-keyword, + %yul-years-keyword, + } + + resource language { + supported-versions: static func() -> list; + new: static func(version: string) -> result; + version: func() -> string; + parse: func(kind: nonterminal-kind, input: string) -> parse-output; + } + + resource parse-error { + // is-a diagnostic + severity: func() -> severity; + text-range: func() -> text-range; + message: func() -> string; + } + + resource parse-output { + tree: func() -> node; + errors: func() -> list; + is-valid: func() -> bool; + create-tree-cursor: func() -> cursor; + } + + variant node { + nonterminal(nonterminal-node), + terminal(terminal-node) + } + + resource nonterminal-node { + kind: func() -> nonterminal-kind; + text-len: func() -> text-index; + children: func() -> list; + create-cursor: func(text-offset: text-index) -> cursor; + unparse: func() -> string; + } + + resource terminal-node { + kind: func() -> terminal-kind; + text-len: func() -> text-index; + text: func() -> string; + } + + resource cursor { + reset: func(); + complete: func(); + is-completed: func() -> bool; + + clone: func() -> cursor; + spawn: func() -> cursor; + + node: func() -> node; + label: func() -> option; + + text-offset: func() -> text-index; + text-range: func() -> text-range; + + depth: func() -> u32; + + ancestors: func() -> list; + + go-to-next: func() -> bool; + go-to-next-non-descendent: func() -> bool; + go-to-previous: func() -> bool; + + go-to-parent: func() -> bool; + + go-to-first-child: func() -> bool; + go-to-last-child: func() -> bool; + go-to-nth-child: func(child-number: u32) -> bool; + + go-to-next-sibling: func() -> bool; + go-to-previous-sibling: func() -> bool; + + go-to-next-terminal: func() -> bool; + go-to-next-terminal-with-kind: func(kind: terminal-kind) -> bool; + go-to-next-terminal-with-kinds: func(kinds: list) -> bool; + + go-to-next-nonterminal: func() -> bool; + go-to-next-nonterminal-with-kind: func(kind: nonterminal-kind) -> bool; + go-to-next-nonterminal-with-kinds: func(kinds: list) -> bool; + + query: func(queries: list>) -> query-match-iterator; + } + + resource query { + parse: static func(text: string) -> result; + } + + record query-error { + message: string, + line: u32, + column: u32, + } + + record query-match { + query-number: u32, + captures: list>>, + } + + resource query-match-iterator { + next: func() -> option; + } + + enum severity { + error, + warning, + information, + hint, + } + + record text-index { + utf8: u32, + utf16: u32, + line: u32, + column: u32, + } + + record text-range { + start: text-index, + end: text-index, + } + +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/kinds.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/kinds.rs new file mode 100644 index 0000000000..20b777598a --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/kinds.rs @@ -0,0 +1,27 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum nonterminal-kind +// +//================================================ + +enum_to_enum!(NonterminalKind); + +//================================================ +// +// enum terminal-kind +// +//================================================ + +enum_to_enum!(TerminalKind); + +//================================================ +// +// enum edge-label +// +//================================================ + +enum_to_enum!(EdgeLabel); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/language.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/language.rs new file mode 100644 index 0000000000..b457fec97f --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/language.rs @@ -0,0 +1,79 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_wrapper, ffi, rust, FromFFI, IntoFFI}; + +use rust::Diagnostic as _; + +//================================================ +// +// resource language +// +//================================================ + +define_wrapper! { Language { + fn new(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid version: {version}")) + .and_then(|version| rust::Language::new(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + + fn supported_versions() -> Vec { + rust::Language::SUPPORTED_VERSIONS + .iter() + .map(|v| v.to_string()) + .collect() + } + + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { + self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() + } +} } + +//================================================ +// +// resource parse-error +// +//================================================ + +define_wrapper! { ParseError { + fn severity(&self) -> ffi::Severity { + self._borrow_ffi().severity()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + fn message(&self) -> String { + self._borrow_ffi().message() + } +} } + +//================================================ +// +// resource parse-output +// +//================================================ + +define_wrapper! { ParseOutput { + fn tree(&self) -> ffi::Node { + self._borrow_ffi().tree()._into_ffi() + } + + fn errors(&self) -> Vec { + self._borrow_ffi().errors().iter().map(|e| e.clone()._into_ffi()).collect() + } + + fn is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } + + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } +} } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/mod.rs new file mode 100644 index 0000000000..6cf53e4de3 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/mod.rs @@ -0,0 +1,248 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +pub mod cst; +pub mod cursor; +pub mod diagnostic; +pub mod kinds; +pub mod language; +pub mod query; +pub mod text_index; + +#[path = "generated/slang.rs"] +pub mod slang; + +// #[path = "generated/ast_selectors.rs"] +// pub mod ast_selectors; + +pub mod ffi { + pub use crate::wit::slang::exports::nomic::slang::parser::{ + Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestLanguage, GuestNonterminalNode, + GuestParseError, GuestParseOutput, GuestQuery, GuestQueryMatchIterator, GuestTerminalNode, + Language, LanguageBorrow, Node, NonterminalKind, NonterminalNode, NonterminalNodeBorrow, + ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Query, QueryBorrow, + QueryError, QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, Severity, + TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, TextRange, + }; +} + +pub mod rust { + pub use crate::{ + cst::{Edge, Node, NonterminalNode, TerminalNode}, + cursor::Cursor, + diagnostic::{Diagnostic, Severity}, + kinds::{EdgeLabel, NonterminalKind, TerminalKind}, + language::Language, + parse_error::ParseError, + parse_output::ParseOutput, + query::{Query, QueryError, QueryMatch, QueryMatchIterator}, + text_index::{TextIndex, TextRange}, + }; +} + +pub trait IntoFFI { + fn _into_ffi(self) -> F; +} + +pub trait FromFFI { + fn _from_ffi(self) -> R; +} + +macro_rules! define_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (rust::$name); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&'a self) -> &'a rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_rc_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::rc::Rc); + + impl $crate::wit::IntoFFI for std::rc::Rc { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI> for ffi::$name { + #[inline] + fn _from_ffi(self) -> std::rc::Rc { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_refcell_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::cell::RefCell); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0.into_inner() + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.0.borrow() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.0.borrow_mut() + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! enum_to_enum { + ($name:ident) => { + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + unsafe { core::mem::transmute(self) } + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + unsafe { core::mem::transmute(self) } + } + } + }; +} + +// The trick: https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files +pub(crate) use {define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum}; + +#[allow(clippy::upper_case_acronyms)] +pub struct API; + +//================================================ +// +// interface language +// +//================================================ + +impl ffi::Guest for API { + type Language = language::LanguageWrapper; + type ParseError = language::ParseErrorWrapper; + type ParseOutput = language::ParseOutputWrapper; + type NonterminalNode = cst::NonterminalNodeWrapper; + type TerminalNode = cst::TerminalNodeWrapper; + type Cursor = cursor::CursorWrapper; + type Query = query::QueryWrapper; + type QueryMatchIterator = query::QueryMatchIteratorWrapper; +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/query.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/query.rs new file mode 100644 index 0000000000..0b66780288 --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/query.rs @@ -0,0 +1,66 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_refcell_wrapper, define_wrapper, ffi, rust, IntoFFI}; + +//================================================ +// +// resource query +// +//================================================ + +define_wrapper! { Query { + fn parse(text: String) -> Result { + rust::Query::parse(&text).map_err(IntoFFI::_into_ffi).map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-error +// +//================================================ + +impl IntoFFI for rust::QueryError { + #[inline] + fn _into_ffi(self) -> ffi::QueryError { + #[allow(clippy::cast_possible_truncation)] + ffi::QueryError { + message: self.message, + line: self.line as u32, + column: self.column as u32, + } + } +} + +//================================================ +// +// resource query-match-iterator +// +//================================================ + +define_refcell_wrapper! { QueryMatchIterator { + fn next(&self) -> Option { + self._borrow_mut_ffi().next().map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-match +// +//================================================ + +impl IntoFFI for rust::QueryMatch { + #[inline] + fn _into_ffi(self) -> ffi::QueryMatch { + ffi::QueryMatch { + #[allow(clippy::cast_possible_truncation)] + query_number: self.query_number as u32, + captures: self + .captures + .into_iter() + .map(|(k, v)| (k, v.into_iter().map(|c| c._into_ffi()).collect())) + .collect(), + } + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/text_index.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/text_index.rs new file mode 100644 index 0000000000..6eec970aca --- /dev/null +++ b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/text_index.rs @@ -0,0 +1,77 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// record text-index +// +//================================================ + +impl IntoFFI for rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + #[allow(clippy::cast_possible_truncation)] + ffi::TextIndex { + utf8: self.utf8 as u32, + utf16: self.utf16 as u32, + line: self.line as u32, + column: self.column as u32, + } + } +} + +impl IntoFFI for &rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + (*self)._into_ffi() + } +} + +impl FromFFI for ffi::TextIndex { + #[inline] + fn _from_ffi(self) -> rust::TextIndex { + rust::TextIndex { + utf8: self.utf8 as usize, + utf16: self.utf16 as usize, + line: self.line as usize, + column: self.column as usize, + } + } +} + +//================================================ +// +// record text-range +// +//================================================ + +impl IntoFFI for rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl IntoFFI for &rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl FromFFI for ffi::TextRange { + #[inline] + fn _from_ffi(self) -> rust::TextRange { + rust::TextRange { + start: self.start._from_ffi(), + end: self.end._from_ffi(), + } + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs index 17d9986a37..e70779dd64 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/main.rs +++ b/crates/solidity/outputs/cargo/slang_solidity/src/main.rs @@ -14,7 +14,8 @@ use slang_solidity::language::Language; // https://github.com/rust-lang/cargo/issues/1982 mod supress_api_dependencies { use { - ariadne as _, metaslang_cst as _, serde as _, strum as _, strum_macros as _, thiserror as _, + ariadne as _, metaslang_cst as _, paste as _, serde as _, strum as _, strum_macros as _, + thiserror as _, }; } diff --git a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml index 49c89cf9eb..2cad8a235d 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml +++ b/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml @@ -14,6 +14,7 @@ testlang_language = { workspace = true } [dependencies] metaslang_cst = { workspace = true } +paste = { workspace = true } semver = { workspace = true } serde = { workspace = true } strum = { workspace = true } diff --git a/crates/testlang/outputs/cargo/slang_testlang/build.rs b/crates/testlang/outputs/cargo/slang_testlang/build.rs index 7b2f00b850..285ef0168b 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/build.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/build.rs @@ -8,5 +8,7 @@ fn main() -> Result<()> { let output_dir = CargoWorkspace::locate_source_crate("slang_testlang")?.join("src/generated"); - OutputLanguage::Cargo.generate_runtime(&language, &output_dir) + OutputLanguage::Cargo.generate_runtime(&language, &output_dir)?; + OutputLanguage::Cargo.wit_bindgen(&output_dir)?; + Ok(()) } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs index 53b7c36e56..65d3f916a0 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/kinds.rs @@ -3,6 +3,8 @@ #[cfg(feature = "slang_napi_interfaces")] use napi_derive::napi; +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -36,6 +38,8 @@ pub enum NonterminalKind { impl metaslang_cst::NonterminalKind for NonterminalKind {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -78,6 +82,8 @@ pub enum EdgeLabel { impl metaslang_cst::EdgeLabel for EdgeLabel {} +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive( Debug, Eq, @@ -123,6 +129,8 @@ impl metaslang_cst::TerminalKind for TerminalKind { } /// The lexical context of the scanner. +// This needs to stay in sync with the wit-bindgen output +#[repr(u8)] #[derive(strum_macros::FromRepr, Clone, Copy)] pub(crate) enum LexicalContext { Default, diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs index aed3cf41f7..1a2da1f0ef 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/generated/language.rs @@ -31,6 +31,7 @@ use crate::parser_support::{ #[derive(Debug)] #[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))] pub struct Language { + #[allow(dead_code)] pub(crate) version_is_at_least_1_0_0: bool, pub(crate) version: Version, } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs index c444d0844e..19e188473c 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs @@ -12,6 +12,9 @@ pub mod language; pub mod parse_error; pub mod parse_output; +#[cfg(feature = "wit")] +pub mod wit; + #[cfg(feature = "slang_napi_interfaces")] pub mod napi_interface; @@ -65,6 +68,7 @@ pub mod query { pub type Query = query::Query; pub type QueryMatch = query::QueryMatch; pub type QueryMatchIterator = query::QueryMatchIterator; + pub use query::QueryError; } pub mod text_index { diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cst.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cst.rs new file mode 100644 index 0000000000..0fea6d85c4 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cst.rs @@ -0,0 +1,67 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_rc_wrapper, ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// resource nonterminal-node +// +//================================================ + +define_rc_wrapper! { NonterminalNode { + fn kind(&self) -> ffi::NonterminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text_len(&self) -> ffi::TextIndex { + self._borrow_ffi().text_len._into_ffi() + } + + fn children(&self) -> Vec { + todo!() + } + + fn create_cursor(&self, text_offset: ffi::TextIndex) -> ffi::Cursor { + std::rc::Rc::clone(self._borrow_ffi()).cursor_with_offset(text_offset._from_ffi())._into_ffi() + } + + fn unparse(&self) -> String { + std::rc::Rc::clone(self._borrow_ffi()).unparse() + } +} } + +//================================================ +// +// resource terminal-node +// +//================================================ + +define_rc_wrapper! { TerminalNode { + fn kind(&self) -> ffi::TerminalKind { + self._borrow_ffi().kind._into_ffi() + } + + fn text(&self) -> String { + self._borrow_ffi().text.clone() + } + + fn text_len(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + } +} } + +//================================================ +// +// variant node +// +//================================================ + +impl IntoFFI for rust::Node { + #[inline] + fn _into_ffi(self) -> ffi::Node { + match self { + Self::Nonterminal(node) => ffi::Node::Nonterminal(node._into_ffi()), + Self::Terminal(node) => ffi::Node::Terminal(node._into_ffi()), + } + } +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cursor.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cursor.rs new file mode 100644 index 0000000000..b9be5d3348 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/cursor.rs @@ -0,0 +1,125 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_refcell_wrapper, ffi, rust, FromFFI, IntoFFI}; +//================================================ +// +// resource cursor +// +//================================================ + +define_refcell_wrapper! { Cursor { + fn reset(&self) { + self._borrow_mut_ffi().reset(); + } + + fn complete(&self) { + self._borrow_mut_ffi().complete(); + } + + fn is_completed(&self) -> bool { + self._borrow_ffi().is_completed() + } + + fn clone(&self) -> ffi::Cursor { + self._borrow_ffi().clone()._into_ffi() + } + + fn spawn(&self) -> ffi::Cursor { + self._borrow_ffi().spawn()._into_ffi() + } + + fn node(&self) -> ffi::Node { + self._borrow_ffi().node()._into_ffi() + } + + fn label(&self) -> Option { + self._borrow_ffi().label().map(IntoFFI::_into_ffi) + } + + fn text_offset(&self) -> ffi::TextIndex { + self._borrow_ffi().text_offset()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + #[allow(clippy::cast_possible_truncation)] + fn depth(&self) -> u32 { + self._borrow_ffi().depth() as u32 + } + + fn ancestors(&self) -> Vec { + self._borrow_ffi().ancestors().map(|x|x._into_ffi()).collect() + } + + fn go_to_next(&self) -> bool { + self._borrow_mut_ffi().go_to_next() + } + + fn go_to_next_non_descendent(&self) -> bool { + self._borrow_mut_ffi().go_to_next_non_descendent() + } + + fn go_to_previous(&self) -> bool { + self._borrow_mut_ffi().go_to_previous() + } + + fn go_to_parent(&self) -> bool { + self._borrow_mut_ffi().go_to_parent() + } + + fn go_to_first_child(&self) -> bool { + self._borrow_mut_ffi().go_to_first_child() + } + + fn go_to_last_child(&self) -> bool { + self._borrow_mut_ffi().go_to_last_child() + } + + fn go_to_nth_child(&self, child_number: u32) -> bool { + self._borrow_mut_ffi().go_to_nth_child(child_number as usize) + } + + fn go_to_next_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_next_sibling() + } + + fn go_to_previous_sibling(&self) -> bool { + self._borrow_mut_ffi().go_to_previous_sibling() + } + + fn go_to_next_terminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_terminal() + } + + fn go_to_next_terminal_with_kind(&self, kind: ffi::TerminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_terminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_terminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_terminal_with_kinds(&kinds) + } + + fn go_to_next_nonterminal(&self) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal() + } + + fn go_to_next_nonterminal_with_kind(&self, kind: ffi::NonterminalKind) -> bool { + self._borrow_mut_ffi().go_to_next_nonterminal_with_kind(kind._from_ffi()) + } + + fn go_to_next_nonterminal_with_kinds(&self, kinds: Vec) -> bool { + let kinds = kinds.into_iter().map(FromFFI::_from_ffi).collect::>(); + self._borrow_mut_ffi().go_to_next_nonterminal_with_kinds(&kinds) + } + + fn query(&self, queries: Vec>) -> ffi::QueryMatchIterator { + let queries:Vec = queries.into_iter().map(|q|{ + q._borrow_ffi().clone() + }).collect(); + + self._borrow_ffi().clone().query(queries)._into_ffi() + } +} } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/diagnostic.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/diagnostic.rs new file mode 100644 index 0000000000..d8c0910196 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/diagnostic.rs @@ -0,0 +1,11 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum severity +// +//================================================ + +enum_to_enum!(Severity); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.rs new file mode 100644 index 0000000000..9f7b1bff2f --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.rs @@ -0,0 +1,3778 @@ +// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! +// Options used: +// * default-bindings-module: "$crate::wit::slang" +// * pub-export-macro +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod nomic { + #[allow(dead_code)] + pub mod slang { + #[allow(dead_code, clippy::all)] + pub mod parser { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = + super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum NonterminalKind { + AdditionExpression, + Expression, + Literal, + MemberAccessExpression, + NegationExpression, + SeparatedIdentifiers, + SourceUnit, + SourceUnitMember, + SourceUnitMembers, + Tree, + TreeNode, + TreeNodeChild, + TreeNodeChildren, + } + impl ::core::fmt::Debug for NonterminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + NonterminalKind::AdditionExpression => f + .debug_tuple("NonterminalKind::AdditionExpression") + .finish(), + NonterminalKind::Expression => { + f.debug_tuple("NonterminalKind::Expression").finish() + } + NonterminalKind::Literal => { + f.debug_tuple("NonterminalKind::Literal").finish() + } + NonterminalKind::MemberAccessExpression => f + .debug_tuple("NonterminalKind::MemberAccessExpression") + .finish(), + NonterminalKind::NegationExpression => f + .debug_tuple("NonterminalKind::NegationExpression") + .finish(), + NonterminalKind::SeparatedIdentifiers => f + .debug_tuple("NonterminalKind::SeparatedIdentifiers") + .finish(), + NonterminalKind::SourceUnit => { + f.debug_tuple("NonterminalKind::SourceUnit").finish() + } + NonterminalKind::SourceUnitMember => { + f.debug_tuple("NonterminalKind::SourceUnitMember").finish() + } + NonterminalKind::SourceUnitMembers => { + f.debug_tuple("NonterminalKind::SourceUnitMembers").finish() + } + NonterminalKind::Tree => { + f.debug_tuple("NonterminalKind::Tree").finish() + } + NonterminalKind::TreeNode => { + f.debug_tuple("NonterminalKind::TreeNode").finish() + } + NonterminalKind::TreeNodeChild => { + f.debug_tuple("NonterminalKind::TreeNodeChild").finish() + } + NonterminalKind::TreeNodeChildren => { + f.debug_tuple("NonterminalKind::TreeNodeChildren").finish() + } + } + } + } + + impl NonterminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> NonterminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => NonterminalKind::AdditionExpression, + 1 => NonterminalKind::Expression, + 2 => NonterminalKind::Literal, + 3 => NonterminalKind::MemberAccessExpression, + 4 => NonterminalKind::NegationExpression, + 5 => NonterminalKind::SeparatedIdentifiers, + 6 => NonterminalKind::SourceUnit, + 7 => NonterminalKind::SourceUnitMember, + 8 => NonterminalKind::SourceUnitMembers, + 9 => NonterminalKind::Tree, + 10 => NonterminalKind::TreeNode, + 11 => NonterminalKind::TreeNodeChild, + 12 => NonterminalKind::TreeNodeChildren, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum EdgeLabel { + /// Built-in: + Item, + Variant, + Separator, + Operand, + LeftOperand, + RightOperand, + LeadingTrivia, + TrailingTrivia, + /// Generated: + CloseBracket, + Keyword, + Member, + Members, + Name, + Node, + OpenBracket, + Operator, + Period, + Semicolon, + } + impl ::core::fmt::Debug for EdgeLabel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + EdgeLabel::Item => f.debug_tuple("EdgeLabel::Item").finish(), + EdgeLabel::Variant => f.debug_tuple("EdgeLabel::Variant").finish(), + EdgeLabel::Separator => f.debug_tuple("EdgeLabel::Separator").finish(), + EdgeLabel::Operand => f.debug_tuple("EdgeLabel::Operand").finish(), + EdgeLabel::LeftOperand => { + f.debug_tuple("EdgeLabel::LeftOperand").finish() + } + EdgeLabel::RightOperand => { + f.debug_tuple("EdgeLabel::RightOperand").finish() + } + EdgeLabel::LeadingTrivia => { + f.debug_tuple("EdgeLabel::LeadingTrivia").finish() + } + EdgeLabel::TrailingTrivia => { + f.debug_tuple("EdgeLabel::TrailingTrivia").finish() + } + EdgeLabel::CloseBracket => { + f.debug_tuple("EdgeLabel::CloseBracket").finish() + } + EdgeLabel::Keyword => f.debug_tuple("EdgeLabel::Keyword").finish(), + EdgeLabel::Member => f.debug_tuple("EdgeLabel::Member").finish(), + EdgeLabel::Members => f.debug_tuple("EdgeLabel::Members").finish(), + EdgeLabel::Name => f.debug_tuple("EdgeLabel::Name").finish(), + EdgeLabel::Node => f.debug_tuple("EdgeLabel::Node").finish(), + EdgeLabel::OpenBracket => { + f.debug_tuple("EdgeLabel::OpenBracket").finish() + } + EdgeLabel::Operator => f.debug_tuple("EdgeLabel::Operator").finish(), + EdgeLabel::Period => f.debug_tuple("EdgeLabel::Period").finish(), + EdgeLabel::Semicolon => f.debug_tuple("EdgeLabel::Semicolon").finish(), + } + } + } + + impl EdgeLabel { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> EdgeLabel { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => EdgeLabel::Item, + 1 => EdgeLabel::Variant, + 2 => EdgeLabel::Separator, + 3 => EdgeLabel::Operand, + 4 => EdgeLabel::LeftOperand, + 5 => EdgeLabel::RightOperand, + 6 => EdgeLabel::LeadingTrivia, + 7 => EdgeLabel::TrailingTrivia, + 8 => EdgeLabel::CloseBracket, + 9 => EdgeLabel::Keyword, + 10 => EdgeLabel::Member, + 11 => EdgeLabel::Members, + 12 => EdgeLabel::Name, + 13 => EdgeLabel::Node, + 14 => EdgeLabel::OpenBracket, + 15 => EdgeLabel::Operator, + 16 => EdgeLabel::Period, + 17 => EdgeLabel::Semicolon, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum TerminalKind { + /// Built-in: + Skipped, + /// Generated: + Bang, + CloseBracket, + DelimitedIdentifier, + EndOfLine, + Identifier, + MultiLineComment, + OpenBracket, + Period, + Plus, + Semicolon, + SingleLineComment, + StringLiteral, + TreeKeyword, + Whitespace, + } + impl ::core::fmt::Debug for TerminalKind { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + TerminalKind::Skipped => { + f.debug_tuple("TerminalKind::Skipped").finish() + } + TerminalKind::Bang => f.debug_tuple("TerminalKind::Bang").finish(), + TerminalKind::CloseBracket => { + f.debug_tuple("TerminalKind::CloseBracket").finish() + } + TerminalKind::DelimitedIdentifier => { + f.debug_tuple("TerminalKind::DelimitedIdentifier").finish() + } + TerminalKind::EndOfLine => { + f.debug_tuple("TerminalKind::EndOfLine").finish() + } + TerminalKind::Identifier => { + f.debug_tuple("TerminalKind::Identifier").finish() + } + TerminalKind::MultiLineComment => { + f.debug_tuple("TerminalKind::MultiLineComment").finish() + } + TerminalKind::OpenBracket => { + f.debug_tuple("TerminalKind::OpenBracket").finish() + } + TerminalKind::Period => f.debug_tuple("TerminalKind::Period").finish(), + TerminalKind::Plus => f.debug_tuple("TerminalKind::Plus").finish(), + TerminalKind::Semicolon => { + f.debug_tuple("TerminalKind::Semicolon").finish() + } + TerminalKind::SingleLineComment => { + f.debug_tuple("TerminalKind::SingleLineComment").finish() + } + TerminalKind::StringLiteral => { + f.debug_tuple("TerminalKind::StringLiteral").finish() + } + TerminalKind::TreeKeyword => { + f.debug_tuple("TerminalKind::TreeKeyword").finish() + } + TerminalKind::Whitespace => { + f.debug_tuple("TerminalKind::Whitespace").finish() + } + } + } + } + + impl TerminalKind { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> TerminalKind { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => TerminalKind::Skipped, + 1 => TerminalKind::Bang, + 2 => TerminalKind::CloseBracket, + 3 => TerminalKind::DelimitedIdentifier, + 4 => TerminalKind::EndOfLine, + 5 => TerminalKind::Identifier, + 6 => TerminalKind::MultiLineComment, + 7 => TerminalKind::OpenBracket, + 8 => TerminalKind::Period, + 9 => TerminalKind::Plus, + 10 => TerminalKind::Semicolon, + 11 => TerminalKind::SingleLineComment, + 12 => TerminalKind::StringLiteral, + 13 => TerminalKind::TreeKeyword, + 14 => TerminalKind::Whitespace, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Language { + handle: _rt::Resource, + } + + type _LanguageRep = Option; + + impl Language { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Language`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _LanguageRep = Some(val); + let ptr: *mut _LanguageRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestLanguage` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _LanguageRep); + } + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Language`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct LanguageBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Language>, + } + + impl<'a> LanguageBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _LanguageRep { + Language::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Language { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]language"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseError { + handle: _rt::Resource, + } + + type _ParseErrorRep = Option; + + impl ParseError { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseError`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseErrorRep = Some(val); + let ptr: *mut _ParseErrorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseError` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseErrorRep); + } + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseError`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseErrorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseError>, + } + + impl<'a> ParseErrorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseErrorRep { + ParseError::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseError { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutput { + handle: _rt::Resource, + } + + type _ParseOutputRep = Option; + + impl ParseOutput { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `ParseOutput`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _ParseOutputRep = Some(val); + let ptr: *mut _ParseOutputRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestParseOutput` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _ParseOutputRep); + } + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`ParseOutput`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct ParseOutputBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a ParseOutput>, + } + + impl<'a> ParseOutputBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _ParseOutputRep { + ParseOutput::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for ParseOutput { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]parse-output"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNode { + handle: _rt::Resource, + } + + type _NonterminalNodeRep = Option; + + impl NonterminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `NonterminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _NonterminalNodeRep = Some(val); + let ptr: *mut _NonterminalNodeRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestNonterminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _NonterminalNodeRep); + } + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`NonterminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct NonterminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a NonterminalNode>, + } + + impl<'a> NonterminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _NonterminalNodeRep { + NonterminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for NonterminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]nonterminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNode { + handle: _rt::Resource, + } + + type _TerminalNodeRep = Option; + + impl TerminalNode { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `TerminalNode`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _TerminalNodeRep = Some(val); + let ptr: *mut _TerminalNodeRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestTerminalNode` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _TerminalNodeRep); + } + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`TerminalNode`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct TerminalNodeBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a TerminalNode>, + } + + impl<'a> TerminalNodeBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _TerminalNodeRep { + TerminalNode::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for TerminalNode { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]terminal-node"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + pub enum Node { + Nonterminal(NonterminalNode), + Terminal(TerminalNode), + } + impl ::core::fmt::Debug for Node { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Node::Nonterminal(e) => { + f.debug_tuple("Node::Nonterminal").field(e).finish() + } + Node::Terminal(e) => f.debug_tuple("Node::Terminal").field(e).finish(), + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Cursor { + handle: _rt::Resource, + } + + type _CursorRep = Option; + + impl Cursor { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Cursor`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _CursorRep = Some(val); + let ptr: *mut _CursorRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestCursor` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _CursorRep); + } + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Cursor`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct CursorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Cursor>, + } + + impl<'a> CursorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _CursorRep { + Cursor::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Cursor { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]cursor"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct Query { + handle: _rt::Resource, + } + + type _QueryRep = Option; + + impl Query { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `Query`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryRep = Some(val); + let ptr: *mut _QueryRep = _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQuery` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryRep); + } + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`Query`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a Query>, + } + + impl<'a> QueryBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryRep { + Query::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for Query { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[derive(Clone)] + pub struct QueryError { + pub message: _rt::String, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryError") + .field("message", &self.message) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + impl ::core::fmt::Display for QueryError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + impl std::error::Error for QueryError {} + pub struct QueryMatch { + pub query_number: u32, + pub captures: _rt::Vec<(_rt::String, _rt::Vec)>, + } + impl ::core::fmt::Debug for QueryMatch { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("QueryMatch") + .field("query-number", &self.query_number) + .field("captures", &self.captures) + .finish() + } + } + + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIterator { + handle: _rt::Resource, + } + + type _QueryMatchIteratorRep = Option; + + impl QueryMatchIterator { + /// Creates a new resource from the specified representation. + /// + /// This function will create a new resource handle by moving `val` onto + /// the heap and then passing that heap pointer to the component model to + /// create a handle. The owned handle is then returned as `QueryMatchIterator`. + pub fn new(val: T) -> Self { + Self::type_guard::(); + let val: _QueryMatchIteratorRep = Some(val); + let ptr: *mut _QueryMatchIteratorRep = + _rt::Box::into_raw(_rt::Box::new(val)); + unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } + } + + /// Gets access to the underlying `T` which represents this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &*self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + /// Gets mutable access to the underlying `T` which represents this + /// resource. + pub fn get_mut(&mut self) -> &mut T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_mut().unwrap() + } + + /// Consumes this resource and returns the underlying `T`. + pub fn into_inner(self) -> T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.take().unwrap() + } + + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + + // It's theoretically possible to implement the `GuestQueryMatchIterator` trait twice + // so guard against using it with two different types here. + #[doc(hidden)] + fn type_guard() { + use core::any::TypeId; + static mut LAST_TYPE: Option = None; + unsafe { + assert!(!cfg!(target_feature = "threads")); + let id = TypeId::of::(); + match LAST_TYPE { + Some(ty) => assert!( + ty == id, + "cannot use two types with this resource type" + ), + None => LAST_TYPE = Some(id), + } + } + } + + #[doc(hidden)] + pub unsafe fn dtor(handle: *mut u8) { + Self::type_guard::(); + let _ = _rt::Box::from_raw(handle as *mut _QueryMatchIteratorRep); + } + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + T::_resource_rep(self.handle()).cast() + } + } + + /// A borrowed version of [`QueryMatchIterator`] which represents a borrowed value + /// with the lifetime `'a`. + #[derive(Debug)] + #[repr(transparent)] + pub struct QueryMatchIteratorBorrow<'a> { + rep: *mut u8, + _marker: core::marker::PhantomData<&'a QueryMatchIterator>, + } + + impl<'a> QueryMatchIteratorBorrow<'a> { + #[doc(hidden)] + pub unsafe fn lift(rep: usize) -> Self { + Self { + rep: rep as *mut u8, + _marker: core::marker::PhantomData, + } + } + + /// Gets access to the underlying `T` in this resource. + pub fn get(&self) -> &T { + let ptr = unsafe { &mut *self.as_ptr::() }; + ptr.as_ref().unwrap() + } + + // NB: mutable access is not allowed due to the component model allowing + // multiple borrows of the same resource. + + fn as_ptr(&self) -> *mut _QueryMatchIteratorRep { + QueryMatchIterator::type_guard::(); + self.rep.cast() + } + } + + unsafe impl _rt::WasmResource for QueryMatchIterator { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-drop]query-match-iterator"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Severity { + Error, + Warning, + Information, + Hint, + } + impl ::core::fmt::Debug for Severity { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Severity::Error => f.debug_tuple("Severity::Error").finish(), + Severity::Warning => f.debug_tuple("Severity::Warning").finish(), + Severity::Information => { + f.debug_tuple("Severity::Information").finish() + } + Severity::Hint => f.debug_tuple("Severity::Hint").finish(), + } + } + } + + impl Severity { + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Severity { + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Severity::Error, + 1 => Severity::Warning, + 2 => Severity::Information, + 3 => Severity::Hint, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextIndex { + pub utf8: u32, + pub utf16: u32, + pub line: u32, + pub column: u32, + } + impl ::core::fmt::Debug for TextIndex { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextIndex") + .field("utf8", &self.utf8) + .field("utf16", &self.utf16) + .field("line", &self.line) + .field("column", &self.column) + .finish() + } + } + #[repr(C)] + #[derive(Clone, Copy)] + pub struct TextRange { + pub start: TextIndex, + pub end: TextIndex, + } + impl ::core::fmt::Debug for TextRange { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TextRange") + .field("start", &self.start) + .field("end", &self.end) + .finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_supported_versions_cabi( + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::supported_versions(); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec3 = result0; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = (e.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + *ptr1.add(4).cast::() = len3; + *ptr1.add(0).cast::<*mut u8>() = result3; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_supported_versions( + arg0: *mut u8, + ) { + let l2 = *arg0.add(0).cast::<*mut u8>(); + let l3 = *arg0.add(4).cast::(); + let base4 = l2; + let len4 = l3; + for i in 0..len4 { + let base = base4.add(i * 8); + { + let l0 = *base.add(0).cast::<*mut u8>(); + let l1 = *base.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + } + _rt::cabi_dealloc(base4, len4 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_language_new_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::new(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let vec3 = (e.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr2.add(8).cast::() = len3; + *ptr2.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_language_new(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_version_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::version(LanguageBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_language_version( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_language_parse_cabi( + arg0: *mut u8, + arg1: i32, + arg2: *mut u8, + arg3: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg3; + let bytes0 = _rt::Vec::from_raw_parts(arg2.cast(), len0, len0); + let result1 = T::parse( + LanguageBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + _rt::string_lift(bytes0), + ); + (result1).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_severity_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::severity(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_error_message_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::message(ParseErrorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_error_message( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_tree_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::tree(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_errors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::errors(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_parse_output_errors( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_is_valid_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_valid(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_parse_output_create_tree_cursor_cabi< + T: GuestParseOutput, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::create_tree_cursor(ParseOutputBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_text_len_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::text_len(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_children_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::children(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + match e { + Node::Nonterminal(e) => { + *base.add(0).cast::() = (0i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(4).cast::() = (e).take_handle() as i32; + } + } + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_children< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 8, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_create_cursor_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::create_cursor( + NonterminalNodeBorrow::lift(arg0 as u32 as usize).get(), + TextIndex { + utf8: arg1 as u32, + utf16: arg2 as u32, + line: arg3 as u32, + column: arg4 as u32, + }, + ); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_nonterminal_node_unparse_cabi< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::unparse(NonterminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_nonterminal_node_unparse< + T: GuestNonterminalNode, + >( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_kind_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::kind(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + result0.clone() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_len_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_len(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_terminal_node_text_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text(TerminalNodeBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + ::core::mem::forget(vec2); + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_terminal_node_text( + arg0: *mut u8, + ) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + _rt::cabi_dealloc(l0, l1, 1); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_reset_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::reset(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_complete_cabi(arg0: *mut u8) { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + T::complete(CursorBorrow::lift(arg0 as u32 as usize).get()); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_is_completed_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::is_completed(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_clone_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::clone(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_spawn_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::spawn(CursorBorrow::lift(arg0 as u32 as usize).get()); + (result0).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_node_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::node(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Node::Nonterminal(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Node::Terminal(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + } + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_label_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::label(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(1).cast::() = (e.clone() as i32) as u8; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_offset_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_offset(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextIndex { + utf8: utf82, + utf16: utf162, + line: line2, + column: column2, + } = result0; + *ptr1.add(0).cast::() = _rt::as_i32(utf82); + *ptr1.add(4).cast::() = _rt::as_i32(utf162); + *ptr1.add(8).cast::() = _rt::as_i32(line2); + *ptr1.add(12).cast::() = _rt::as_i32(column2); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_text_range_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::text_range(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let TextRange { + start: start2, + end: end2, + } = result0; + let TextIndex { + utf8: utf83, + utf16: utf163, + line: line3, + column: column3, + } = start2; + *ptr1.add(0).cast::() = _rt::as_i32(utf83); + *ptr1.add(4).cast::() = _rt::as_i32(utf163); + *ptr1.add(8).cast::() = _rt::as_i32(line3); + *ptr1.add(12).cast::() = _rt::as_i32(column3); + let TextIndex { + utf8: utf84, + utf16: utf164, + line: line4, + column: column4, + } = end2; + *ptr1.add(16).cast::() = _rt::as_i32(utf84); + *ptr1.add(20).cast::() = _rt::as_i32(utf164); + *ptr1.add(24).cast::() = _rt::as_i32(line4); + *ptr1.add(28).cast::() = _rt::as_i32(column4); + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_depth_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::depth(CursorBorrow::lift(arg0 as u32 as usize).get()); + _rt::as_i32(result0) + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_ancestors_cabi( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::ancestors(CursorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + let vec2 = result0; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 4, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *ptr1.add(4).cast::() = len2; + *ptr1.add(0).cast::<*mut u8>() = result2; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_cursor_ancestors(arg0: *mut u8) { + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base2 = l0; + let len2 = l1; + _rt::cabi_dealloc(base2, len2 * 4, 4); + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_non_descendent_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_non_descendent( + CursorBorrow::lift(arg0 as u32 as usize).get(), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_previous(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_parent_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_parent(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_first_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_first_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_last_child_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_last_child(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_nth_child_cabi( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_nth_child( + CursorBorrow::lift(arg0 as u32 as usize).get(), + arg1 as u32, + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_previous_sibling_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_previous_sibling(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_terminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_terminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + TerminalKind::_lift(arg1 as u8), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_terminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 1); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + TerminalKind::_lift(l0 as u8) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 1, 1); + let result2 = T::go_to_next_terminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_cabi( + arg0: *mut u8, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::go_to_next_nonterminal(CursorBorrow::lift(arg0 as u32 as usize).get()); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kind_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: i32, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = T::go_to_next_nonterminal_with_kind( + CursorBorrow::lift(arg0 as u32 as usize).get(), + NonterminalKind::_lift(arg1 as u8), + ); + match result0 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_go_to_next_nonterminal_with_kinds_cabi< + T: GuestCursor, + >( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 1); + let e1 = { + let l0 = i32::from(*base.add(0).cast::()); + + NonterminalKind::_lift(l0 as u8) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 1, 1); + let result2 = T::go_to_next_nonterminal_with_kinds( + CursorBorrow::lift(arg0 as u32 as usize).get(), + result1, + ); + match result2 { + true => 1, + false => 0, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_cursor_query_cabi( + arg0: *mut u8, + arg1: *mut u8, + arg2: usize, + ) -> i32 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let base1 = arg1; + let len1 = arg2; + let mut result1 = _rt::Vec::with_capacity(len1); + for i in 0..len1 { + let base = base1.add(i * 4); + let e1 = { + let l0 = *base.add(0).cast::(); + + QueryBorrow::lift(l0 as u32 as usize) + }; + result1.push(e1); + } + _rt::cabi_dealloc(base1, len1 * 4, 4); + let result2 = T::query(CursorBorrow::lift(arg0 as u32 as usize).get(), result1); + (result2).take_handle() as i32 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_static_query_parse_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let result1 = T::parse(_rt::string_lift(bytes0)); + let ptr2 = _RET_AREA.0.as_mut_ptr().cast::(); + match result1 { + Ok(e) => { + *ptr2.add(0).cast::() = (0i32) as u8; + *ptr2.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr2.add(0).cast::() = (1i32) as u8; + let QueryError { + message: message3, + line: line3, + column: column3, + } = e; + let vec4 = (message3.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *ptr2.add(8).cast::() = len4; + *ptr2.add(4).cast::<*mut u8>() = ptr4.cast_mut(); + *ptr2.add(12).cast::() = _rt::as_i32(line3); + *ptr2.add(16).cast::() = _rt::as_i32(column3); + } + }; + ptr2 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_static_query_parse(arg0: *mut u8) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + } + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_method_query_match_iterator_next_cabi< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] + _rt::run_ctors_once(); + let result0 = + T::next(QueryMatchIteratorBorrow::lift(arg0 as u32 as usize).get()); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let QueryMatch { + query_number: query_number2, + captures: captures2, + } = e; + *ptr1.add(4).cast::() = _rt::as_i32(query_number2); + let vec6 = captures2; + let len6 = vec6.len(); + let layout6 = + _rt::alloc::Layout::from_size_align_unchecked(vec6.len() * 16, 4); + let result6 = if layout6.size() != 0 { + let ptr = _rt::alloc::alloc(layout6).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout6); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6.add(i * 16); + { + let (t3_0, t3_1) = e; + let vec4 = (t3_0.into_bytes()).into_boxed_slice(); + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + ::core::mem::forget(vec4); + *base.add(4).cast::() = len4; + *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); + let vec5 = t3_1; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked( + vec5.len() * 4, + 4, + ); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 4); + { + *base.add(0).cast::() = (e).take_handle() as i32; + } + } + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = result5; + } + } + *ptr1.add(12).cast::() = len6; + *ptr1.add(8).cast::<*mut u8>() = result6; + } + None => { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }; + ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_method_query_match_iterator_next< + T: GuestQueryMatchIterator, + >( + arg0: *mut u8, + ) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l6 = *arg0.add(8).cast::<*mut u8>(); + let l7 = *arg0.add(12).cast::(); + let base8 = l6; + let len8 = l7; + for i in 0..len8 { + let base = base8.add(i * 16); + { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(8).cast::<*mut u8>(); + let l4 = *base.add(12).cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); + } + } + _rt::cabi_dealloc(base8, len8 * 16, 4); + } + } + } + pub trait Guest { + type Language: GuestLanguage; + type ParseError: GuestParseError; + type ParseOutput: GuestParseOutput; + type NonterminalNode: GuestNonterminalNode; + type TerminalNode: GuestTerminalNode; + type Cursor: GuestCursor; + type Query: GuestQuery; + type QueryMatchIterator: GuestQueryMatchIterator; + } + pub trait GuestLanguage: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]language"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]language"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn supported_versions() -> _rt::Vec<_rt::String>; + fn new(version: _rt::String) -> Result; + fn version(&self) -> _rt::String; + fn parse(&self, kind: NonterminalKind, input: _rt::String) -> ParseOutput; + } + pub trait GuestParseError: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-error"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-error"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + /// is-a diagnostic + fn severity(&self) -> Severity; + fn text_range(&self) -> TextRange; + fn message(&self) -> _rt::String; + } + pub trait GuestParseOutput: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]parse-output"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]parse-output"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn tree(&self) -> Node; + fn errors(&self) -> _rt::Vec; + fn is_valid(&self) -> bool; + fn create_tree_cursor(&self) -> Cursor; + } + pub trait GuestNonterminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]nonterminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]nonterminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> NonterminalKind; + fn text_len(&self) -> TextIndex; + fn children(&self) -> _rt::Vec; + fn create_cursor(&self, text_offset: TextIndex) -> Cursor; + fn unparse(&self) -> _rt::String; + } + pub trait GuestTerminalNode: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]terminal-node"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]terminal-node"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn kind(&self) -> TerminalKind; + fn text_len(&self) -> TextIndex; + fn text(&self) -> _rt::String; + } + pub trait GuestCursor: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]cursor"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]cursor"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn reset(&self); + fn complete(&self); + fn is_completed(&self) -> bool; + fn clone(&self) -> Cursor; + fn spawn(&self) -> Cursor; + fn node(&self) -> Node; + fn label(&self) -> Option; + fn text_offset(&self) -> TextIndex; + fn text_range(&self) -> TextRange; + fn depth(&self) -> u32; + fn ancestors(&self) -> _rt::Vec; + fn go_to_next(&self) -> bool; + fn go_to_next_non_descendent(&self) -> bool; + fn go_to_previous(&self) -> bool; + fn go_to_parent(&self) -> bool; + fn go_to_first_child(&self) -> bool; + fn go_to_last_child(&self) -> bool; + fn go_to_nth_child(&self, child_number: u32) -> bool; + fn go_to_next_sibling(&self) -> bool; + fn go_to_previous_sibling(&self) -> bool; + fn go_to_next_terminal(&self) -> bool; + fn go_to_next_terminal_with_kind(&self, kind: TerminalKind) -> bool; + fn go_to_next_terminal_with_kinds(&self, kinds: _rt::Vec) + -> bool; + fn go_to_next_nonterminal(&self) -> bool; + fn go_to_next_nonterminal_with_kind(&self, kind: NonterminalKind) -> bool; + fn go_to_next_nonterminal_with_kinds( + &self, + kinds: _rt::Vec, + ) -> bool; + fn query(&self, queries: _rt::Vec>) -> QueryMatchIterator; + } + pub trait GuestQuery: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn parse(text: _rt::String) -> Result; + } + pub trait GuestQueryMatchIterator: 'static { + #[doc(hidden)] + unsafe fn _resource_new(val: *mut u8) -> u32 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = val; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-new]query-match-iterator"] + fn new(_: *mut u8) -> u32; + } + new(val) + } + } + + #[doc(hidden)] + fn _resource_rep(handle: u32) -> *mut u8 + where + Self: Sized, + { + #[cfg(not(target_arch = "wasm32"))] + { + let _ = handle; + unreachable!(); + } + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "[export]nomic:slang/parser@1.0.0")] + extern "C" { + #[link_name = "[resource-rep]query-match-iterator"] + fn rep(_: u32) -> *mut u8; + } + unsafe { rep(handle) } + } + } + + fn next(&self) -> Option; + } + #[doc(hidden)] + #[macro_export] + macro_rules! __export_nomic_slang_parser_1_0_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn export_static_language_supported_versions() -> *mut u8 { + $($path_to_types)*::_export_static_language_supported_versions_cabi::<<$ty as $($path_to_types)*::Guest>::Language>() + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.supported-versions"] + unsafe extern "C" fn _post_return_static_language_supported_versions(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_supported_versions::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn export_static_language_new(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_language_new_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]language.new"] + unsafe extern "C" fn _post_return_static_language_new(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_language_new::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn export_method_language_version(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_language_version_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]language.version"] + unsafe extern "C" fn _post_return_method_language_version(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_language_version::<<$ty as $($path_to_types)*::Guest>::Language>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]language.parse"] + unsafe extern "C" fn export_method_language_parse(arg0: *mut u8,arg1: i32,arg2: *mut u8,arg3: usize,) -> i32 { + $($path_to_types)*::_export_method_language_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Language>(arg0, arg1, arg2, arg3) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.severity"] + unsafe extern "C" fn export_method_parse_error_severity(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_error_severity_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.text-range"] + unsafe extern "C" fn export_method_parse_error_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn export_method_parse_error_message(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_error_message_cabi::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-error.message"] + unsafe extern "C" fn _post_return_method_parse_error_message(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_error_message::<<$ty as $($path_to_types)*::Guest>::ParseError>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.tree"] + unsafe extern "C" fn export_method_parse_output_tree(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_tree_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn export_method_parse_output_errors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_parse_output_errors_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]parse-output.errors"] + unsafe extern "C" fn _post_return_method_parse_output_errors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_parse_output_errors::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.is-valid"] + unsafe extern "C" fn export_method_parse_output_is_valid(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_is_valid_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]parse-output.create-tree-cursor"] + unsafe extern "C" fn export_method_parse_output_create_tree_cursor(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_parse_output_create_tree_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::ParseOutput>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.kind"] + unsafe extern "C" fn export_method_nonterminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.text-len"] + unsafe extern "C" fn export_method_nonterminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn export_method_nonterminal_node_children(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_children_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.children"] + unsafe extern "C" fn _post_return_method_nonterminal_node_children(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_children::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.create-cursor"] + unsafe extern "C" fn export_method_nonterminal_node_create_cursor(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,) -> i32 { + $($path_to_types)*::_export_method_nonterminal_node_create_cursor_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0, arg1, arg2, arg3, arg4) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn export_method_nonterminal_node_unparse(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_nonterminal_node_unparse_cabi::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]nonterminal-node.unparse"] + unsafe extern "C" fn _post_return_method_nonterminal_node_unparse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_nonterminal_node_unparse::<<$ty as $($path_to_types)*::Guest>::NonterminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.kind"] + unsafe extern "C" fn export_method_terminal_node_kind(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_terminal_node_kind_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text-len"] + unsafe extern "C" fn export_method_terminal_node_text_len(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_len_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn export_method_terminal_node_text(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_terminal_node_text_cabi::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]terminal-node.text"] + unsafe extern "C" fn _post_return_method_terminal_node_text(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_terminal_node_text::<<$ty as $($path_to_types)*::Guest>::TerminalNode>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.reset"] + unsafe extern "C" fn export_method_cursor_reset(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_reset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.complete"] + unsafe extern "C" fn export_method_cursor_complete(arg0: *mut u8,) { + $($path_to_types)*::_export_method_cursor_complete_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.is-completed"] + unsafe extern "C" fn export_method_cursor_is_completed(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_is_completed_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.clone"] + unsafe extern "C" fn export_method_cursor_clone(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_clone_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.spawn"] + unsafe extern "C" fn export_method_cursor_spawn(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_spawn_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.node"] + unsafe extern "C" fn export_method_cursor_node(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_node_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.label"] + unsafe extern "C" fn export_method_cursor_label(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_label_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-offset"] + unsafe extern "C" fn export_method_cursor_text_offset(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_offset_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.text-range"] + unsafe extern "C" fn export_method_cursor_text_range(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_text_range_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.depth"] + unsafe extern "C" fn export_method_cursor_depth(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_depth_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn export_method_cursor_ancestors(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_cursor_ancestors_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]cursor.ancestors"] + unsafe extern "C" fn _post_return_method_cursor_ancestors(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_cursor_ancestors::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next"] + unsafe extern "C" fn export_method_cursor_go_to_next(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-non-descendent"] + unsafe extern "C" fn export_method_cursor_go_to_next_non_descendent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_non_descendent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous"] + unsafe extern "C" fn export_method_cursor_go_to_previous(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-parent"] + unsafe extern "C" fn export_method_cursor_go_to_parent(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_parent_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-first-child"] + unsafe extern "C" fn export_method_cursor_go_to_first_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_first_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-last-child"] + unsafe extern "C" fn export_method_cursor_go_to_last_child(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_last_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-nth-child"] + unsafe extern "C" fn export_method_cursor_go_to_nth_child(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_nth_child_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_next_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-previous-sibling"] + unsafe extern "C" fn export_method_cursor_go_to_previous_sibling(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_previous_sibling_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-terminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_terminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_terminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal(arg0: *mut u8,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kind"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kind(arg0: *mut u8,arg1: i32,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kind_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.go-to-next-nonterminal-with-kinds"] + unsafe extern "C" fn export_method_cursor_go_to_next_nonterminal_with_kinds(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_go_to_next_nonterminal_with_kinds_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]cursor.query"] + unsafe extern "C" fn export_method_cursor_query(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> i32 { + $($path_to_types)*::_export_method_cursor_query_cabi::<<$ty as $($path_to_types)*::Guest>::Cursor>(arg0, arg1, arg2) + } + #[export_name = "nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn export_static_query_parse(arg0: *mut u8,arg1: usize,) -> *mut u8 { + $($path_to_types)*::_export_static_query_parse_cabi::<<$ty as $($path_to_types)*::Guest>::Query>(arg0, arg1) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[static]query.parse"] + unsafe extern "C" fn _post_return_static_query_parse(arg0: *mut u8,) { + $($path_to_types)*::__post_return_static_query_parse::<<$ty as $($path_to_types)*::Guest>::Query>(arg0) + } + #[export_name = "nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn export_method_query_match_iterator_next(arg0: *mut u8,) -> *mut u8 { + $($path_to_types)*::_export_method_query_match_iterator_next_cabi::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + #[export_name = "cabi_post_nomic:slang/parser@1.0.0#[method]query-match-iterator.next"] + unsafe extern "C" fn _post_return_method_query_match_iterator_next(arg0: *mut u8,) { + $($path_to_types)*::__post_return_method_query_match_iterator_next::<<$ty as $($path_to_types)*::Guest>::QueryMatchIterator>(arg0) + } + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]language"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Language::dtor::< + <$ty as $($path_to_types)*::Guest>::Language + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-error"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseError::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseError + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]parse-output"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::ParseOutput::dtor::< + <$ty as $($path_to_types)*::Guest>::ParseOutput + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]nonterminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::NonterminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::NonterminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]terminal-node"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::TerminalNode::dtor::< + <$ty as $($path_to_types)*::Guest>::TerminalNode + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]cursor"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Cursor::dtor::< + <$ty as $($path_to_types)*::Guest>::Cursor + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::Query::dtor::< + <$ty as $($path_to_types)*::Guest>::Query + >(rep) + } + }; + + + const _: () = { + #[doc(hidden)] + #[export_name = "nomic:slang/parser@1.0.0#[dtor]query-match-iterator"] + #[allow(non_snake_case)] + unsafe extern "C" fn dtor(rep: *mut u8) { + $($path_to_types)*::QueryMatchIterator::dtor::< + <$ty as $($path_to_types)*::Guest>::QueryMatchIterator + >(rep) + } + }; + + };); +} + #[doc(hidden)] + pub use __export_nomic_slang_parser_1_0_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 32]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 32]); + } + } + } +} +mod _rt { + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + pub use alloc_crate::boxed::Box; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen::rt::run_ctors_once(); + } + pub use alloc_crate::alloc; + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr as *mut u8, layout); + } + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] +#[macro_export] +macro_rules! __export_slang_impl { + ($ty:ident) => ($crate::wit::slang::export!($ty with_types_in $crate::wit::slang);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::nomic::slang::parser::__export_nomic_slang_parser_1_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::nomic::slang::parser); + const _: () = { + + #[cfg(target_arch = "wasm32")] + #[link_section = "component-type:wit-bindgen:0.26.0:slang:imports and exports"] + #[doc(hidden)] + pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 3431] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xeb\x19\x01A\x02\x01\ +A\x02\x01B\x8c\x01\x01m\x0d\x13addition-expression\x0aexpression\x07literal\x18m\ +ember-access-expression\x13negation-expression\x15separated-identifiers\x0bsourc\ +e-unit\x12source-unit-member\x13source-unit-members\x04tree\x09tree-node\x0ftree\ +-node-child\x12tree-node-children\x04\0\x10nonterminal-kind\x03\0\0\x01m\x12\x04\ +item\x07variant\x09separator\x07operand\x0cleft-operand\x0dright-operand\x0elead\ +ing-trivia\x0ftrailing-trivia\x0dclose-bracket\x07keyword\x06member\x07members\x04\ +name\x04node\x0copen-bracket\x08operator\x06period\x09semicolon\x04\0\x0aedge-la\ +bel\x03\0\x02\x01m\x0f\x07skipped\x04bang\x0dclose-bracket\x14delimited-identifi\ +er\x0bend-of-line\x0aidentifier\x12multi-line-comment\x0copen-bracket\x06period\x04\ +plus\x09semicolon\x13single-line-comment\x0estring-literal\x0ctree-keyword\x0awh\ +itespace\x04\0\x0dterminal-kind\x03\0\x04\x04\0\x08language\x03\x01\x04\0\x0bpar\ +se-error\x03\x01\x04\0\x0cparse-output\x03\x01\x04\0\x10nonterminal-node\x03\x01\ +\x04\0\x0dterminal-node\x03\x01\x01i\x09\x01i\x0a\x01q\x02\x0bnonterminal\x01\x0b\ +\0\x08terminal\x01\x0c\0\x04\0\x04node\x03\0\x0d\x04\0\x06cursor\x03\x01\x04\0\x05\ +query\x03\x01\x01r\x03\x07messages\x04liney\x06columny\x04\0\x0bquery-error\x03\0\ +\x11\x01i\x0f\x01p\x13\x01o\x02s\x14\x01p\x15\x01r\x02\x0cquery-numbery\x08captu\ +res\x16\x04\0\x0bquery-match\x03\0\x17\x04\0\x14query-match-iterator\x03\x01\x01\ +m\x04\x05error\x07warning\x0binformation\x04hint\x04\0\x08severity\x03\0\x1a\x01\ +r\x04\x04utf8y\x05utf16y\x04liney\x06columny\x04\0\x0atext-index\x03\0\x1c\x01r\x02\ +\x05start\x1d\x03end\x1d\x04\0\x0atext-range\x03\0\x1e\x01ps\x01@\0\0\x20\x04\0#\ +[static]language.supported-versions\x01!\x01i\x06\x01j\x01\"\x01s\x01@\x01\x07ve\ +rsions\0#\x04\0\x14[static]language.new\x01$\x01h\x06\x01@\x01\x04self%\0s\x04\0\ +\x18[method]language.version\x01&\x01i\x08\x01@\x03\x04self%\x04kind\x01\x05inpu\ +ts\0'\x04\0\x16[method]language.parse\x01(\x01h\x07\x01@\x01\x04self)\0\x1b\x04\0\ +\x1c[method]parse-error.severity\x01*\x01@\x01\x04self)\0\x1f\x04\0\x1e[method]p\ +arse-error.text-range\x01+\x01@\x01\x04self)\0s\x04\0\x1b[method]parse-error.mes\ +sage\x01,\x01h\x08\x01@\x01\x04self-\0\x0e\x04\0\x19[method]parse-output.tree\x01\ +.\x01i\x07\x01p/\x01@\x01\x04self-\00\x04\0\x1b[method]parse-output.errors\x011\x01\ +@\x01\x04self-\0\x7f\x04\0\x1d[method]parse-output.is-valid\x012\x01@\x01\x04sel\ +f-\0\x13\x04\0'[method]parse-output.create-tree-cursor\x013\x01h\x09\x01@\x01\x04\ +self4\0\x01\x04\0\x1d[method]nonterminal-node.kind\x015\x01@\x01\x04self4\0\x1d\x04\ +\0![method]nonterminal-node.text-len\x016\x01p\x0e\x01@\x01\x04self4\07\x04\0![m\ +ethod]nonterminal-node.children\x018\x01@\x02\x04self4\x0btext-offset\x1d\0\x13\x04\ +\0&[method]nonterminal-node.create-cursor\x019\x01@\x01\x04self4\0s\x04\0\x20[me\ +thod]nonterminal-node.unparse\x01:\x01h\x0a\x01@\x01\x04self;\0\x05\x04\0\x1a[me\ +thod]terminal-node.kind\x01<\x01@\x01\x04self;\0\x1d\x04\0\x1e[method]terminal-n\ +ode.text-len\x01=\x01@\x01\x04self;\0s\x04\0\x1a[method]terminal-node.text\x01>\x01\ +h\x0f\x01@\x01\x04self?\x01\0\x04\0\x14[method]cursor.reset\x01@\x04\0\x17[metho\ +d]cursor.complete\x01@\x01@\x01\x04self?\0\x7f\x04\0\x1b[method]cursor.is-comple\ +ted\x01A\x01@\x01\x04self?\0\x13\x04\0\x14[method]cursor.clone\x01B\x04\0\x14[me\ +thod]cursor.spawn\x01B\x01@\x01\x04self?\0\x0e\x04\0\x13[method]cursor.node\x01C\ +\x01k\x03\x01@\x01\x04self?\0\xc4\0\x04\0\x14[method]cursor.label\x01E\x01@\x01\x04\ +self?\0\x1d\x04\0\x1a[method]cursor.text-offset\x01F\x01@\x01\x04self?\0\x1f\x04\ +\0\x19[method]cursor.text-range\x01G\x01@\x01\x04self?\0y\x04\0\x14[method]curso\ +r.depth\x01H\x01p\x0b\x01@\x01\x04self?\0\xc9\0\x04\0\x18[method]cursor.ancestor\ +s\x01J\x04\0\x19[method]cursor.go-to-next\x01A\x04\0([method]cursor.go-to-next-n\ +on-descendent\x01A\x04\0\x1d[method]cursor.go-to-previous\x01A\x04\0\x1b[method]\ +cursor.go-to-parent\x01A\x04\0\x20[method]cursor.go-to-first-child\x01A\x04\0\x1f\ +[method]cursor.go-to-last-child\x01A\x01@\x02\x04self?\x0cchild-numbery\0\x7f\x04\ +\0\x1e[method]cursor.go-to-nth-child\x01K\x04\0![method]cursor.go-to-next-siblin\ +g\x01A\x04\0%[method]cursor.go-to-previous-sibling\x01A\x04\0\"[method]cursor.go\ +-to-next-terminal\x01A\x01@\x02\x04self?\x04kind\x05\0\x7f\x04\0,[method]cursor.\ +go-to-next-terminal-with-kind\x01L\x01p\x05\x01@\x02\x04self?\x05kinds\xcd\0\0\x7f\ +\x04\0-[method]cursor.go-to-next-terminal-with-kinds\x01N\x04\0%[method]cursor.g\ +o-to-next-nonterminal\x01A\x01@\x02\x04self?\x04kind\x01\0\x7f\x04\0/[method]cur\ +sor.go-to-next-nonterminal-with-kind\x01O\x01p\x01\x01@\x02\x04self?\x05kinds\xd0\ +\0\0\x7f\x04\00[method]cursor.go-to-next-nonterminal-with-kinds\x01Q\x01h\x10\x01\ +p\xd2\0\x01i\x19\x01@\x02\x04self?\x07queries\xd3\0\0\xd4\0\x04\0\x14[method]cur\ +sor.query\x01U\x01i\x10\x01j\x01\xd6\0\x01\x12\x01@\x01\x04texts\0\xd7\0\x04\0\x13\ +[static]query.parse\x01X\x01h\x19\x01k\x18\x01@\x01\x04self\xd9\0\0\xda\0\x04\0!\ +[method]query-match-iterator.next\x01[\x04\x01\x18nomic:slang/parser@1.0.0\x05\0\ +\x04\x01\x17nomic:slang/slang@1.0.0\x04\0\x0b\x0b\x01\0\x05slang\x03\0\0\0G\x09p\ +roducers\x01\x0cprocessed-by\x02\x0dwit-component\x070.209.1\x10wit-bindgen-rust\ +\x060.26.0"; + }; + ) +} +#[doc(inline)] +pub use __export_slang_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.26.0:slang-with-all-of-its-exports-removed:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 221] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07B\x01A\x02\x01A\0\x04\ +\x017nomic:slang/slang-with-all-of-its-exports-removed@1.0.0\x04\0\x0b+\x01\0%sl\ +ang-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ +\x0dwit-component\x070.209.1\x10wit-bindgen-rust\x060.26.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen::rt::maybe_link_cabi_realloc(); +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.wit b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.wit new file mode 100644 index 0000000000..f53f568194 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/generated/slang.wit @@ -0,0 +1,192 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +package nomic:slang@1.0.0; + +world slang { + export parser; +} + +interface parser { + + enum nonterminal-kind { + %addition-expression, + %expression, + %literal, + %member-access-expression, + %negation-expression, + %separated-identifiers, + %source-unit, + %source-unit-member, + %source-unit-members, + %tree, + %tree-node, + %tree-node-child, + %tree-node-children, + } + + enum edge-label { + // Built-in: + %item, + %variant, + %separator, + %operand, + %left-operand, + %right-operand, + %leading-trivia, + %trailing-trivia, + + // Generated: + %close-bracket, + %keyword, + %member, + %members, + %name, + %node, + %open-bracket, + %operator, + %period, + %semicolon, + } + + enum terminal-kind { + // Built-in: + skipped, + + // Generated: + %bang, + %close-bracket, + %delimited-identifier, + %end-of-line, + %identifier, + %multi-line-comment, + %open-bracket, + %period, + %plus, + %semicolon, + %single-line-comment, + %string-literal, + %tree-keyword, + %whitespace, + } + + resource language { + supported-versions: static func() -> list; + new: static func(version: string) -> result; + version: func() -> string; + parse: func(kind: nonterminal-kind, input: string) -> parse-output; + } + + resource parse-error { + // is-a diagnostic + severity: func() -> severity; + text-range: func() -> text-range; + message: func() -> string; + } + + resource parse-output { + tree: func() -> node; + errors: func() -> list; + is-valid: func() -> bool; + create-tree-cursor: func() -> cursor; + } + + variant node { + nonterminal(nonterminal-node), + terminal(terminal-node) + } + + resource nonterminal-node { + kind: func() -> nonterminal-kind; + text-len: func() -> text-index; + children: func() -> list; + create-cursor: func(text-offset: text-index) -> cursor; + unparse: func() -> string; + } + + resource terminal-node { + kind: func() -> terminal-kind; + text-len: func() -> text-index; + text: func() -> string; + } + + resource cursor { + reset: func(); + complete: func(); + is-completed: func() -> bool; + + clone: func() -> cursor; + spawn: func() -> cursor; + + node: func() -> node; + label: func() -> option; + + text-offset: func() -> text-index; + text-range: func() -> text-range; + + depth: func() -> u32; + + ancestors: func() -> list; + + go-to-next: func() -> bool; + go-to-next-non-descendent: func() -> bool; + go-to-previous: func() -> bool; + + go-to-parent: func() -> bool; + + go-to-first-child: func() -> bool; + go-to-last-child: func() -> bool; + go-to-nth-child: func(child-number: u32) -> bool; + + go-to-next-sibling: func() -> bool; + go-to-previous-sibling: func() -> bool; + + go-to-next-terminal: func() -> bool; + go-to-next-terminal-with-kind: func(kind: terminal-kind) -> bool; + go-to-next-terminal-with-kinds: func(kinds: list) -> bool; + + go-to-next-nonterminal: func() -> bool; + go-to-next-nonterminal-with-kind: func(kind: nonterminal-kind) -> bool; + go-to-next-nonterminal-with-kinds: func(kinds: list) -> bool; + + query: func(queries: list>) -> query-match-iterator; + } + + resource query { + parse: static func(text: string) -> result; + } + + record query-error { + message: string, + line: u32, + column: u32, + } + + record query-match { + query-number: u32, + captures: list>>, + } + + resource query-match-iterator { + next: func() -> option; + } + + enum severity { + error, + warning, + information, + hint, + } + + record text-index { + utf8: u32, + utf16: u32, + line: u32, + column: u32, + } + + record text-range { + start: text-index, + end: text-index, + } + +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/kinds.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/kinds.rs new file mode 100644 index 0000000000..20b777598a --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/kinds.rs @@ -0,0 +1,27 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{enum_to_enum, ffi, rust}; + +//================================================ +// +// enum nonterminal-kind +// +//================================================ + +enum_to_enum!(NonterminalKind); + +//================================================ +// +// enum terminal-kind +// +//================================================ + +enum_to_enum!(TerminalKind); + +//================================================ +// +// enum edge-label +// +//================================================ + +enum_to_enum!(EdgeLabel); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/language.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/language.rs new file mode 100644 index 0000000000..b457fec97f --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/language.rs @@ -0,0 +1,79 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_wrapper, ffi, rust, FromFFI, IntoFFI}; + +use rust::Diagnostic as _; + +//================================================ +// +// resource language +// +//================================================ + +define_wrapper! { Language { + fn new(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid version: {version}")) + .and_then(|version| rust::Language::new(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + + fn supported_versions() -> Vec { + rust::Language::SUPPORTED_VERSIONS + .iter() + .map(|v| v.to_string()) + .collect() + } + + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { + self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() + } +} } + +//================================================ +// +// resource parse-error +// +//================================================ + +define_wrapper! { ParseError { + fn severity(&self) -> ffi::Severity { + self._borrow_ffi().severity()._into_ffi() + } + + fn text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } + + fn message(&self) -> String { + self._borrow_ffi().message() + } +} } + +//================================================ +// +// resource parse-output +// +//================================================ + +define_wrapper! { ParseOutput { + fn tree(&self) -> ffi::Node { + self._borrow_ffi().tree()._into_ffi() + } + + fn errors(&self) -> Vec { + self._borrow_ffi().errors().iter().map(|e| e.clone()._into_ffi()).collect() + } + + fn is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } + + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } +} } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/mod.rs new file mode 100644 index 0000000000..6cf53e4de3 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/mod.rs @@ -0,0 +1,248 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +pub mod cst; +pub mod cursor; +pub mod diagnostic; +pub mod kinds; +pub mod language; +pub mod query; +pub mod text_index; + +#[path = "generated/slang.rs"] +pub mod slang; + +// #[path = "generated/ast_selectors.rs"] +// pub mod ast_selectors; + +pub mod ffi { + pub use crate::wit::slang::exports::nomic::slang::parser::{ + Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestLanguage, GuestNonterminalNode, + GuestParseError, GuestParseOutput, GuestQuery, GuestQueryMatchIterator, GuestTerminalNode, + Language, LanguageBorrow, Node, NonterminalKind, NonterminalNode, NonterminalNodeBorrow, + ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Query, QueryBorrow, + QueryError, QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, Severity, + TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, TextRange, + }; +} + +pub mod rust { + pub use crate::{ + cst::{Edge, Node, NonterminalNode, TerminalNode}, + cursor::Cursor, + diagnostic::{Diagnostic, Severity}, + kinds::{EdgeLabel, NonterminalKind, TerminalKind}, + language::Language, + parse_error::ParseError, + parse_output::ParseOutput, + query::{Query, QueryError, QueryMatch, QueryMatchIterator}, + text_index::{TextIndex, TextRange}, + }; +} + +pub trait IntoFFI { + fn _into_ffi(self) -> F; +} + +pub trait FromFFI { + fn _from_ffi(self) -> R; +} + +macro_rules! define_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (rust::$name); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&'a self) -> &'a rust::$name { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &rust::$name { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_rc_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::rc::Rc); + + impl $crate::wit::IntoFFI for std::rc::Rc { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](self)) + } + } + + impl $crate::wit::FromFFI> for ffi::$name { + #[inline] + fn _from_ffi(self) -> std::rc::Rc { + self.into_inner::<[<$name Wrapper>]>().0 + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> &std::rc::Rc { + &self.0 + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! define_refcell_wrapper { + ($name:ident $impl:tt) => { + paste::paste! { + #[repr(transparent)] + pub struct [<$name Wrapper>] (std::cell::RefCell); + + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + self.into_inner::<[<$name Wrapper>]>().0.into_inner() + } + } + + // As owned argument + impl ffi:: $name { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As borrowed argument + impl<'a> ffi:: [<$name Borrow>] <'a> { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_ffi() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.get::<[<$name Wrapper>]>()._borrow_mut_ffi() + } + } + + // As self + impl [<$name Wrapper>] { + #[inline] + pub fn _borrow_ffi(&self) -> std::cell::Ref<'_, rust::$name> { + self.0.borrow() + } + #[inline] + pub fn _borrow_mut_ffi(&self) -> std::cell::RefMut<'_, rust::$name> { + self.0.borrow_mut() + } + } + + impl ffi:: [] for [<$name Wrapper>] $impl + } + }; +} + +macro_rules! enum_to_enum { + ($name:ident) => { + impl $crate::wit::IntoFFI for rust::$name { + #[inline] + fn _into_ffi(self) -> ffi::$name { + unsafe { core::mem::transmute(self) } + } + } + + impl $crate::wit::FromFFI for ffi::$name { + #[inline] + fn _from_ffi(self) -> rust::$name { + unsafe { core::mem::transmute(self) } + } + } + }; +} + +// The trick: https://stackoverflow.com/questions/26731243/how-do-i-use-a-macro-across-module-files +pub(crate) use {define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum}; + +#[allow(clippy::upper_case_acronyms)] +pub struct API; + +//================================================ +// +// interface language +// +//================================================ + +impl ffi::Guest for API { + type Language = language::LanguageWrapper; + type ParseError = language::ParseErrorWrapper; + type ParseOutput = language::ParseOutputWrapper; + type NonterminalNode = cst::NonterminalNodeWrapper; + type TerminalNode = cst::TerminalNodeWrapper; + type Cursor = cursor::CursorWrapper; + type Query = query::QueryWrapper; + type QueryMatchIterator = query::QueryMatchIteratorWrapper; +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/query.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/query.rs new file mode 100644 index 0000000000..0b66780288 --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/query.rs @@ -0,0 +1,66 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{define_refcell_wrapper, define_wrapper, ffi, rust, IntoFFI}; + +//================================================ +// +// resource query +// +//================================================ + +define_wrapper! { Query { + fn parse(text: String) -> Result { + rust::Query::parse(&text).map_err(IntoFFI::_into_ffi).map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-error +// +//================================================ + +impl IntoFFI for rust::QueryError { + #[inline] + fn _into_ffi(self) -> ffi::QueryError { + #[allow(clippy::cast_possible_truncation)] + ffi::QueryError { + message: self.message, + line: self.line as u32, + column: self.column as u32, + } + } +} + +//================================================ +// +// resource query-match-iterator +// +//================================================ + +define_refcell_wrapper! { QueryMatchIterator { + fn next(&self) -> Option { + self._borrow_mut_ffi().next().map(IntoFFI::_into_ffi) + } +} } + +//================================================ +// +// record query-match +// +//================================================ + +impl IntoFFI for rust::QueryMatch { + #[inline] + fn _into_ffi(self) -> ffi::QueryMatch { + ffi::QueryMatch { + #[allow(clippy::cast_possible_truncation)] + query_number: self.query_number as u32, + captures: self + .captures + .into_iter() + .map(|(k, v)| (k, v.into_iter().map(|c| c._into_ffi()).collect())) + .collect(), + } + } +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/text_index.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/text_index.rs new file mode 100644 index 0000000000..6eec970aca --- /dev/null +++ b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/text_index.rs @@ -0,0 +1,77 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +use super::{ffi, rust, FromFFI, IntoFFI}; + +//================================================ +// +// record text-index +// +//================================================ + +impl IntoFFI for rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + #[allow(clippy::cast_possible_truncation)] + ffi::TextIndex { + utf8: self.utf8 as u32, + utf16: self.utf16 as u32, + line: self.line as u32, + column: self.column as u32, + } + } +} + +impl IntoFFI for &rust::TextIndex { + #[inline] + fn _into_ffi(self) -> ffi::TextIndex { + (*self)._into_ffi() + } +} + +impl FromFFI for ffi::TextIndex { + #[inline] + fn _from_ffi(self) -> rust::TextIndex { + rust::TextIndex { + utf8: self.utf8 as usize, + utf16: self.utf16 as usize, + line: self.line as usize, + column: self.column as usize, + } + } +} + +//================================================ +// +// record text-range +// +//================================================ + +impl IntoFFI for rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl IntoFFI for &rust::TextRange { + #[inline] + fn _into_ffi(self) -> ffi::TextRange { + ffi::TextRange { + start: self.start._into_ffi(), + end: self.end._into_ffi(), + } + } +} + +impl FromFFI for ffi::TextRange { + #[inline] + fn _from_ffi(self) -> rust::TextRange { + rust::TextRange { + start: self.start._from_ffi(), + end: self.end._from_ffi(), + } + } +}