From 4c08c9ec2e03bed55a7f836aeebe2a9cae1ba18a Mon Sep 17 00:00:00 2001 From: OmarTawfik <15987992+OmarTawfik@users.noreply.github.com> Date: Fri, 4 Oct 2024 04:20:07 -0700 Subject: [PATCH] migrate NAPI front-end to WASM and ESM --- .changeset/calm-ghosts-melt.md | 5 + .changeset/cold-emus-arrive.md | 5 + .changeset/config.json | 3 +- .changeset/custom-changelog-generator.js | 14 - .changeset/lucky-fireants-design.md | 5 + .changeset/spotty-pigs-beg.md | 5 + .changeset/stale-spoons-join.md | 5 + .changeset/unlucky-tables-carry.md | 5 + .changeset/wicked-jobs-rest.md | 5 + .cspell.json | 3 +- .gitmodules | 4 + .prettierignore | 6 + .vscode/settings.json | 2 +- Cargo.lock | 199 +- Cargo.toml | 36 +- bin/.zig-0.11.0.pkg | 1 - bin/zig | 1 - crates/codegen/runtime/cargo/build.rs | 6 - .../runtime/cargo/{ => crate}/Cargo.toml | 12 +- crates/codegen/runtime/cargo/crate/build.rs | 9 + crates/codegen/runtime/cargo/crate/src/lib.rs | 7 + .../runtime/bindings/binding_rules.rs.jinja2 | 0 .../bindings/generated/binding_rules.rs | 0 .../{ => crate}/src/runtime/bindings/mod.rs | 0 .../src/runtime/cst/edge_label.rs.jinja2 | 36 + .../src/runtime/cst/generated/edge_label.rs | 36 + .../runtime/cst/generated/lexical_context.rs | 20 + .../runtime/cst/generated/nonterminal_kind.rs | 25 + .../runtime/cst/generated/terminal_kind.rs | 39 + .../src/runtime/cst/lexical_context.rs.jinja2 | 36 + .../cargo/{ => crate}/src/runtime/cst/mod.rs | 19 +- .../runtime/cst/nonterminal_kind.rs.jinja2 | 30 + .../src/runtime/cst/terminal_kind.rs.jinja2 | 53 + .../{ => crate}/src/runtime/diagnostic/mod.rs | 5 +- .../runtime/cargo/crate/src/runtime/mod.rs | 5 + .../src/runtime/parser/generated/parser.rs | 64 +- .../src/runtime/parser/lexer/mod.rs | 0 .../{ => crate}/src/runtime/parser/mod.rs | 0 .../src/runtime/parser/parse_error.rs | 0 .../src/runtime/parser/parse_output.rs | 0 .../src/runtime/parser/parser.rs.jinja2 | 58 +- .../parser/parser_support/choice_helper.rs | 0 .../runtime/parser/parser_support/context.rs | 0 .../src/runtime/parser/parser_support/mod.rs | 0 .../parser/parser_support/optional_helper.rs | 0 .../parser/parser_support/parser_function.rs | 0 .../parser/parser_support/parser_result.rs | 0 .../parser_support/precedence_helper.rs | 0 .../runtime/parser/parser_support/recovery.rs | 0 .../parser_support/repetition_helper.rs | 0 .../parser/parser_support/separated_helper.rs | 0 .../parser/parser_support/sequence_helper.rs | 0 .../src/runtime/parser/scanner_macros/mod.rs | 0 crates/codegen/runtime/cargo/src/lib.rs | 5 - .../cargo/src/runtime/cli/commands/mod.rs | 1 - .../cargo/src/runtime/cst/generated/kinds.rs | 124 -- .../cargo/src/runtime/cst/kinds.rs.jinja2 | 164 -- .../codegen/runtime/cargo/src/runtime/mod.rs | 15 - .../napi_interface/ast_selectors.rs.jinja2 | 234 -- .../cargo/src/runtime/napi_interface/cst.rs | 480 ---- .../src/runtime/napi_interface/diagnostic.rs | 78 - .../napi_interface/generated/ast_selectors.rs | 153 -- .../cargo/src/runtime/napi_interface/mod.rs | 23 - .../src/runtime/napi_interface/parser/mod.rs | 5 - .../napi_interface/parser/parse_error.rs | 19 - .../napi_interface/parser/parse_output.rs | 39 - .../runtime/wit/interface/_types.rs.jinja2 | 10 - .../wit/interface/diagnostic.wit.jinja2 | 8 - .../runtime/wit/interface/generated/_types.rs | 8 - .../wit/interface/generated/diagnostic.wit | 10 - .../runtime/cargo/src/runtime/wit/mod.rs | 8 - .../src/runtime/wit/wrappers/diagnostic.rs | 17 - crates/codegen/runtime/cargo/wasm/Cargo.toml | 27 + crates/codegen/runtime/cargo/wasm/build.rs | 9 + crates/codegen/runtime/cargo/wasm/src/lib.rs | 7 + .../cargo/wasm/src/runtime/bindings.rs.jinja2 | 8 + .../cargo/wasm/src/runtime/config.json.jinja2 | 139 ++ .../wasm/src/runtime/generated/bindings.rs | 6 + .../wasm/src/runtime/generated/config.json | 139 ++ .../wasm/src/runtime/interface/ast.wit.jinja2 | 10 + .../src/runtime}/interface/cst.wit.jinja2 | 47 +- .../src/runtime/interface/generated/ast.wit | 12 + .../src/runtime}/interface/generated/cst.wit | 51 +- .../runtime}/interface/generated/parser.wit | 6 +- .../runtime/interface/generated/world.wit} | 2 +- .../src/runtime}/interface/parser.wit.jinja2 | 6 +- .../src/runtime/interface/world.wit.jinja2} | 2 +- .../runtime/cargo/wasm/src/runtime/mod.rs | 8 + .../runtime/wit => wasm/src/runtime}/utils.rs | 16 +- .../wrappers/ast/generated/selectors.rs | 111 + .../wasm/src/runtime/wrappers/ast/mod.rs | 54 + .../runtime/wrappers/ast/selectors.rs.jinja2 | 191 ++ .../src/runtime/wrappers/cst/mod.rs} | 155 +- .../wit => wasm/src/runtime}/wrappers/mod.rs | 2 +- .../src/runtime/wrappers/parser/mod.rs} | 74 +- crates/codegen/runtime/generator/src/lib.rs | 34 +- crates/codegen/runtime/node_addon/Cargo.toml | 49 - crates/codegen/runtime/node_addon/build.rs | 6 - crates/codegen/runtime/npm/build.rs | 6 - crates/codegen/runtime/npm/package.json | 17 - crates/codegen/runtime/npm/package/.gitignore | 3 + .../runtime/npm/{ => package}/CHANGELOG.md | 0 .../runtime/npm/{ => package}/Cargo.toml | 3 +- .../codegen/runtime/npm/{ => package}/LICENSE | 0 .../runtime/npm/{ => package}/README.md | 0 crates/codegen/runtime/npm/package/build.rs | 9 + .../codegen/runtime/npm/package/package.json | 16 + .../runtime/npm/{ => package}/src/lib.rs | 0 .../src/runtime/ast/generated/nodes.mts} | 0 .../npm/package/src/runtime/ast/index.mts | 1 + .../src/runtime/ast/nodes.mts.jinja2} | 27 +- .../npm/package/src/runtime/cst/index.mts | 79 + .../runtime/npm/package/src/runtime/index.mts | 3 + .../src/runtime/parser/index.mts} | 6 +- .../codegen/runtime/npm/package/tsconfig.json | 12 + .../codegen_runtime_cargo_wasm.component.d.ts | 18 + .../nomic-foundation-slang-ast.d.ts | 16 + .../nomic-foundation-slang-cst.d.ts | 147 ++ .../nomic-foundation-slang-parser.d.ts | 35 + .../interfaces/wasi-cli-environment.d.ts | 5 + .../generated/interfaces/wasi-cli-exit.d.ts | 6 + .../generated/interfaces/wasi-cli-stderr.d.ts | 7 + .../generated/interfaces/wasi-cli-stdin.d.ts | 7 + .../generated/interfaces/wasi-cli-stdout.d.ts | 7 + .../interfaces/wasi-clocks-wall-clock.d.ts | 7 + .../interfaces/wasi-filesystem-preopens.d.ts | 7 + .../interfaces/wasi-filesystem-types.d.ts | 172 ++ .../generated/interfaces/wasi-io-error.d.ts} | 6 +- .../generated/interfaces/wasi-io-streams.d.ts | 25 + .../runtime/npm/package/wasm/index.mts | 1 + .../runtime/npm/src/runtime/ast/index.ts | 1 - .../runtime/npm/src/runtime/cst/index.ts | 36 - .../npm/src/runtime/diagnostic/index.ts | 18 - .../codegen/runtime/npm/src/runtime/index.ts | 3 - .../napi-bindings/generated/index.d.ts | 162 -- .../runtime/napi-bindings/generated/index.js | 299 --- crates/codegen/runtime/npm/tsconfig.json | 20 - crates/infra/cli/Cargo.toml | 2 - crates/infra/cli/src/commands/check/mod.rs | 6 +- .../src/commands/publish/changesets/mod.rs | 16 +- .../infra/cli/src/commands/publish/npm/mod.rs | 73 +- .../infra/cli/src/commands/setup/cargo/mod.rs | 13 + .../infra/cli/src/commands/setup/git/mod.rs | 23 +- .../infra/cli/src/commands/setup/npm/mod.rs | 18 + crates/infra/cli/src/commands/test/mod.rs | 5 +- crates/infra/cli/src/main.rs | 5 +- crates/infra/cli/src/toolchains/mod.rs | 3 +- .../napi/bindings/index.d.ts.jinja2 | 12 - .../toolchains/napi/bindings/index.js.jinja2 | 12 - crates/infra/cli/src/toolchains/napi/cli.rs | 102 - .../infra/cli/src/toolchains/napi/compiler.rs | 180 -- .../infra/cli/src/toolchains/napi/config.rs | 90 - crates/infra/cli/src/toolchains/napi/glibc.rs | 219 -- crates/infra/cli/src/toolchains/napi/mod.rs | 10 - .../infra/cli/src/toolchains/napi/resolver.rs | 81 - crates/infra/cli/src/toolchains/npm/mod.rs | 42 + crates/infra/cli/src/toolchains/wasm/mod.rs | 190 ++ crates/infra/utils/src/codegen/formatting.rs | 60 +- crates/infra/utils/src/codegen/runtime.rs | 10 +- crates/infra/utils/src/paths/extensions.rs | 30 + crates/infra/utils/src/paths/walker.rs | 4 + crates/infra/utils/src/terminal/mod.rs | 7 +- crates/metaslang/bindings/Cargo.toml | 1 + crates/metaslang/cst/generated/public_api.txt | 10 +- crates/metaslang/cst/src/nodes.rs | 59 +- crates/metaslang/cst/src/query/model.rs | 4 +- crates/metaslang/cst/src/query/parser.rs | 4 +- crates/metaslang/graph_builder/src/parser.rs | 6 +- .../metaslang/graph_builder/tests/parser.rs | 4 +- .../inputs/language/src/definition.rs | 4 +- .../{slang_solidity => cli}/CHANGELOG.md | 0 .../{slang_solidity_cli => cli}/Cargo.toml | 5 +- .../cargo/{slang_solidity => cli}/LICENSE | 0 .../{slang_solidity_cli => cli}/README.md | 0 .../outputs/cargo/cli/src/main.rs} | 6 +- .../outputs/cargo/cli/src}/parse.rs | 7 +- .../CHANGELOG.md | 0 .../{slang_solidity => crate}/Cargo.toml | 9 +- .../{slang_solidity_cli => crate}/LICENSE | 0 .../cargo/{slang_solidity => crate}/README.md | 0 .../cargo/{slang_solidity => crate}/build.rs | 7 +- .../generated/public_api.txt | 8 +- .../bindings/generated/binding_rules.rs | 0 .../src/generated/bindings/mod.rs | 0 .../src/generated/cst/generated/edge_label.rs | 157 ++ .../cst/generated/lexical_context.rs | 42 + .../cst/generated/nonterminal_kind.rs | 240 ++ .../generated/cst/generated/terminal_kind.rs | 409 ++++ .../cargo/crate}/src/generated/cst/mod.rs | 19 +- .../crate}/src/generated/diagnostic/mod.rs | 5 +- .../outputs/cargo/crate}/src/generated/mod.rs | 14 +- .../src/generated/parser/generated/parser.rs | 72 +- .../src/generated/parser/lexer/mod.rs | 0 .../src/generated/parser/mod.rs | 0 .../src/generated/parser/parse_error.rs | 0 .../src/generated/parser/parse_output.rs | 0 .../parser/parser_support/choice_helper.rs | 0 .../parser/parser_support/context.rs | 0 .../generated/parser/parser_support/mod.rs | 0 .../parser/parser_support/optional_helper.rs | 0 .../parser/parser_support/parser_function.rs | 0 .../parser/parser_support/parser_result.rs | 0 .../parser_support/precedence_helper.rs | 0 .../parser/parser_support/recovery.rs | 0 .../parser_support/repetition_helper.rs | 0 .../parser/parser_support/separated_helper.rs | 0 .../parser/parser_support/sequence_helper.rs | 0 .../generated/parser/scanner_macros/mod.rs | 0 .../{slang_solidity => crate}/src/lib.rs | 0 .../src/generated/cli/commands/parse.rs | 60 - .../slang_solidity/src/generated/cli/mod.rs | 33 - .../src/generated/cst/generated/kinds.rs | 852 -------- .../src/generated/napi_interface/cst.rs | 482 ----- .../generated/napi_interface/diagnostic.rs | 80 - .../napi_interface/generated/ast_selectors.rs | 1928 ----------------- .../src/generated/napi_interface/mod.rs | 25 - .../generated/napi_interface/parser/mod.rs | 7 - .../napi_interface/parser/parse_error.rs | 21 - .../napi_interface/parser/parse_output.rs | 41 - .../wit/interface/generated/_types.rs | 8 - .../wit/interface/generated/diagnostic.wit | 10 - .../slang_solidity/src/generated/wit/mod.rs | 10 - .../src/generated/wit/wrappers/diagnostic.rs | 19 - .../cargo/slang_solidity_cli/src/main.rs | 3 - .../slang_solidity_node_addon/Cargo.toml | 51 - .../cargo/slang_solidity_node_addon/build.rs | 6 - .../solidity/outputs/cargo/tests/Cargo.toml | 1 + .../tests/src/bindings_assertions/runner.rs | 2 +- .../cargo/tests/src/bindings_output/runner.rs | 2 +- .../cargo/tests/src/cst_output/runner.rs | 2 +- .../src/doc_examples/tree_query_language.rs | 2 +- .../tests/src/doc_examples/using_queries.rs | 2 +- .../src/doc_examples/using_the_cursor.rs | 5 +- .../src/doc_examples/using_the_parser.rs | 6 +- .../outputs/cargo/tests/src/trivia.rs | 2 +- crates/solidity/outputs/cargo/wasm/Cargo.toml | 28 + crates/solidity/outputs/cargo/wasm/build.rs | 16 + .../wasm/src/generated/generated/bindings.rs | 6 + .../wasm/src/generated/generated/config.json | 139 ++ .../src/generated/interface/generated/ast.wit | 12 + .../generated}/interface/generated/cst.wit | 309 +-- .../generated}/interface/generated/parser.wit | 6 +- .../generated/interface/generated/world.wit} | 2 +- .../outputs/cargo/wasm/src/generated/mod.rs | 10 + .../cargo/wasm/src/generated}/utils.rs | 16 +- .../wrappers/ast/generated/selectors.rs | 1632 ++++++++++++++ .../wasm/src/generated/wrappers/ast/mod.rs | 56 + .../wasm/src/generated/wrappers/cst/mod.rs} | 155 +- .../src/generated}/wrappers/mod.rs | 2 +- .../src/generated/wrappers/parser/mod.rs} | 74 +- crates/solidity/outputs/cargo/wasm/src/lib.rs | 3 + .../solidity/outputs/npm/package/.gitignore | 3 + .../solidity/outputs/npm/package/.npmignore | 10 + crates/solidity/outputs/npm/package/build.rs | 7 +- .../solidity/outputs/npm/package/package.json | 51 +- .../platforms/darwin-arm64/CHANGELOG.md | 378 ---- .../package/platforms/darwin-arm64/README.md | 5 - .../platforms/darwin-arm64/package.json | 52 - .../package/platforms/darwin-x64/CHANGELOG.md | 378 ---- .../package/platforms/darwin-x64/README.md | 5 - .../package/platforms/darwin-x64/package.json | 52 - .../platforms/linux-arm64-gnu/CHANGELOG.md | 378 ---- .../platforms/linux-arm64-gnu/README.md | 5 - .../platforms/linux-arm64-gnu/package.json | 52 - .../platforms/linux-arm64-musl/CHANGELOG.md | 378 ---- .../platforms/linux-arm64-musl/README.md | 5 - .../platforms/linux-arm64-musl/package.json | 52 - .../platforms/linux-x64-gnu/CHANGELOG.md | 378 ---- .../package/platforms/linux-x64-gnu/README.md | 5 - .../platforms/linux-x64-gnu/package.json | 52 - .../platforms/linux-x64-musl/CHANGELOG.md | 378 ---- .../platforms/linux-x64-musl/README.md | 5 - .../platforms/linux-x64-musl/package.json | 52 - .../platforms/win32-arm64-msvc/CHANGELOG.md | 378 ---- .../platforms/win32-arm64-msvc/README.md | 5 - .../platforms/win32-arm64-msvc/package.json | 52 - .../platforms/win32-ia32-msvc/CHANGELOG.md | 378 ---- .../platforms/win32-ia32-msvc/README.md | 5 - .../platforms/win32-ia32-msvc/package.json | 52 - .../platforms/win32-x64-msvc/CHANGELOG.md | 378 ---- .../platforms/win32-x64-msvc/README.md | 5 - .../platforms/win32-x64-msvc/package.json | 52 - .../ast/generated/{ast_types.ts => nodes.mts} | 754 +++---- .../package/src/generated/ast/index.mts} | 2 +- .../npm/package/src/generated/cst/index.mts | 81 + .../npm/package/src/generated/cst/index.ts | 38 - .../package/src/generated/diagnostic/index.ts | 20 - .../npm/package/src/generated/index.mts | 5 + .../npm/package/src/generated/index.ts | 5 - .../napi-bindings/generated/index.d.ts | 864 -------- .../napi-bindings/generated/index.js | 299 --- .../package/src/generated/parser/index.mts} | 6 +- .../outputs/npm/package/tsconfig.json | 10 +- .../nomic-foundation-slang-ast.d.ts | 16 + .../nomic-foundation-slang-cst.d.ts | 849 ++++++++ .../nomic-foundation-slang-parser.d.ts | 35 + .../interfaces/wasi-cli-environment.d.ts | 5 + .../generated/interfaces/wasi-cli-exit.d.ts | 6 + .../generated/interfaces/wasi-cli-stderr.d.ts | 7 + .../generated/interfaces/wasi-cli-stdin.d.ts | 7 + .../generated/interfaces/wasi-cli-stdout.d.ts | 7 + .../interfaces/wasi-clocks-wall-clock.d.ts | 7 + .../interfaces/wasi-filesystem-preopens.d.ts | 7 + .../interfaces/wasi-filesystem-types.d.ts | 172 ++ .../generated/interfaces/wasi-io-error.d.ts | 7 + .../generated/interfaces/wasi-io-streams.d.ts | 25 + .../solidity_cargo_wasm.component.d.ts | 18 + .../outputs/npm/package/wasm/index.mts | 1 + .../solidity/outputs/npm/tests/jest.config.ts | 14 +- .../solidity/outputs/npm/tests/package.json | 5 + .../tests/src/doc-examples/using-queries.mts | 139 ++ .../tests/src/doc-examples/using-queries.ts | 158 -- .../{using-the-ast.ts => using-the-ast.mts} | 16 +- ...ing-the-cursor.ts => using-the-cursor.mts} | 23 +- .../src/doc-examples/using-the-parser.mts | 55 + .../src/doc-examples/using-the-parser.ts | 53 - .../outputs/npm/tests/src/utils/files.mts | 13 + .../outputs/npm/tests/src/utils/files.ts | 9 - .../solidity/outputs/npm/tests/tsconfig.json | 9 +- .../outputs/spec/generated/grammar.ebnf | 4 +- .../01-file-structure/03-pragma-directives.md | 6 +- .../testing/perf/benches/iai/tests/parser.rs | 2 +- crates/solidity/testing/sanctuary/Cargo.toml | 2 +- .../solidity/testing/sanctuary/src/tests.rs | 2 +- .../abi_coder/generated/0.4.11-success.yml | 2 +- .../{slang_testlang => crate}/Cargo.toml | 9 +- .../cargo/{slang_testlang => crate}/build.rs | 7 +- .../bindings/generated/binding_rules.rs | 0 .../src/generated/bindings/mod.rs | 0 .../src/generated/cst/generated/edge_label.rs | 43 + .../cst/generated/lexical_context.rs | 34 + .../cst/generated/nonterminal_kind.rs | 35 + .../generated/cst/generated/terminal_kind.rs | 52 + .../cargo/crate}/src/generated/cst/mod.rs | 19 +- .../crate}/src/generated/diagnostic/mod.rs | 5 +- .../outputs/cargo/crate}/src/generated/mod.rs | 14 +- .../src/generated/parser/generated/parser.rs | 64 +- .../src/generated/parser/lexer/mod.rs | 0 .../src/generated/parser/mod.rs | 0 .../src/generated/parser/parse_error.rs | 0 .../src/generated/parser/parse_output.rs | 0 .../parser/parser_support/choice_helper.rs | 0 .../parser/parser_support/context.rs | 0 .../generated/parser/parser_support/mod.rs | 0 .../parser/parser_support/optional_helper.rs | 0 .../parser/parser_support/parser_function.rs | 0 .../parser/parser_support/parser_result.rs | 0 .../parser_support/precedence_helper.rs | 0 .../parser/parser_support/recovery.rs | 0 .../parser_support/repetition_helper.rs | 0 .../parser/parser_support/separated_helper.rs | 0 .../parser/parser_support/sequence_helper.rs | 0 .../generated/parser/scanner_macros/mod.rs | 0 .../{slang_testlang => crate}/src/lib.rs | 0 .../src/generated/cli/commands/parse.rs | 60 - .../slang_testlang/src/generated/cli/mod.rs | 33 - .../src/generated/cst/generated/kinds.rs | 168 -- .../src/generated/napi_interface/cst.rs | 482 ----- .../generated/napi_interface/diagnostic.rs | 80 - .../napi_interface/generated/ast_selectors.rs | 262 --- .../src/generated/napi_interface/mod.rs | 25 - .../generated/napi_interface/parser/mod.rs | 7 - .../napi_interface/parser/parse_error.rs | 21 - .../napi_interface/parser/parse_output.rs | 41 - .../wit/interface/generated/_types.rs | 8 - .../wit/interface/generated/diagnostic.wit | 10 - .../slang_testlang/src/generated/wit/mod.rs | 10 - .../src/generated/wit/wrappers/diagnostic.rs | 19 - .../slang_testlang_node_addon/Cargo.toml | 51 - .../cargo/slang_testlang_node_addon/build.rs | 6 - .../outputs/cargo/tests/src/errors/mod.rs | 2 +- .../outputs/cargo/tests/src/graph/mod.rs | 2 +- .../cargo/tests/src/query/parser_tests.rs | 8 +- crates/testlang/outputs/cargo/wasm/Cargo.toml | 28 + crates/testlang/outputs/cargo/wasm/build.rs | 16 + .../wasm/src/generated/generated/bindings.rs | 6 + .../wasm/src/generated/generated/config.json | 139 ++ .../src/generated/interface/generated/ast.wit | 12 + .../generated}/interface/generated/cst.wit | 73 +- .../generated}/interface/generated/parser.wit | 6 +- .../generated/interface/generated/world.wit} | 2 +- .../outputs/cargo/wasm/src/generated/mod.rs | 10 + .../cargo/wasm/src/generated}/utils.rs | 16 +- .../wrappers/ast/generated/selectors.rs | 216 ++ .../wasm/src/generated/wrappers/ast/mod.rs | 56 + .../wasm/src/generated/wrappers/cst/mod.rs} | 155 +- .../src/generated}/wrappers/mod.rs | 2 +- .../src/generated/wrappers/parser/mod.rs} | 74 +- crates/testlang/outputs/cargo/wasm/src/lib.rs | 3 + .../testlang/outputs/npm/package/.gitignore | 3 + crates/testlang/outputs/npm/package/build.rs | 7 +- .../testlang/outputs/npm/package/package.json | 23 +- .../ast/generated/{ast_types.ts => nodes.mts} | 53 +- .../package/src/generated/ast/index.mts} | 2 +- .../npm/package/src/generated/ast/index.ts | 3 - .../npm/package/src/generated/cst/index.mts | 81 + .../npm/package/src/generated/cst/index.ts | 38 - .../package/src/generated/diagnostic/index.ts | 20 - .../npm/package/src/generated/index.mts | 5 + .../npm/package/src/generated/index.ts | 5 - .../napi-bindings/generated/index.d.ts | 190 -- .../napi-bindings/generated/index.js | 299 --- .../package/src/generated/parser/index.mts} | 6 +- .../outputs/npm/package/tsconfig.json | 10 +- .../nomic-foundation-slang-ast.d.ts | 16 + .../nomic-foundation-slang-cst.d.ts | 175 ++ .../nomic-foundation-slang-parser.d.ts | 35 + .../interfaces/wasi-cli-environment.d.ts | 5 + .../generated/interfaces/wasi-cli-exit.d.ts | 6 + .../generated/interfaces/wasi-cli-stderr.d.ts | 7 + .../generated/interfaces/wasi-cli-stdin.d.ts | 7 + .../generated/interfaces/wasi-cli-stdout.d.ts | 7 + .../interfaces/wasi-clocks-wall-clock.d.ts | 7 + .../interfaces/wasi-filesystem-preopens.d.ts | 7 + .../interfaces/wasi-filesystem-types.d.ts | 172 ++ .../generated/interfaces/wasi-io-error.d.ts | 7 + .../generated/interfaces/wasi-io-streams.d.ts | 25 + .../testlang_cargo_wasm.component.d.ts | 18 + .../outputs/npm/package/wasm/index.mts | 1 + .../testlang/outputs/npm/tests/jest.config.ts | 14 +- .../testlang/outputs/npm/tests/package.json | 5 + .../outputs/npm/tests/src/tests/ast.ts | 196 -- .../outputs/npm/tests/src/tests/ast/ast.mts | 203 ++ .../outputs/npm/tests/src/tests/cst-cursor.ts | 115 - .../outputs/npm/tests/src/tests/cst-output.ts | 78 - .../npm/tests/src/tests/cst/cursor.mts | 125 ++ .../outputs/npm/tests/src/tests/cst/nodes.mts | 53 + .../outputs/npm/tests/src/tests/cst/query.mts | 56 + .../tests/cst/terminal-kind-extensions.mts | 69 + .../outputs/npm/tests/src/tests/errors.ts | 24 - .../tests/src/tests/parser/parse-error.mts | 20 + .../npm/tests/src/tests/parser/parse.mts | 57 + .../npm/tests/src/tests/parser/root-kind.mts | 6 + .../npm/tests/src/tests/parser/versions.mts | 18 + .../outputs/npm/tests/src/tests/public-api.ts | 19 - .../outputs/npm/tests/src/tests/query.ts | 36 - .../outputs/npm/tests/src/tests/versions.ts | 10 - .../npm/tests/src/utils/cst-helpers.ts | 24 - .../outputs/npm/tests/src/utils/files.ts | 9 - .../testlang/outputs/npm/tests/tsconfig.json | 9 +- .../public/assets/javascripts/tsconfig.json | 2 +- .../user-guide/npm-package/using-queries.md | 12 +- .../user-guide/npm-package/using-the-ast.md | 10 +- .../npm-package/using-the-cursor.md | 10 +- .../npm-package/using-the-parser.md | 12 +- package-lock.json | 228 +- package.json | 11 +- scripts/bin/infra | 2 +- submodules/jco | 1 + tsconfig.json | 9 +- 450 files changed, 9668 insertions(+), 16111 deletions(-) create mode 100644 .changeset/calm-ghosts-melt.md create mode 100644 .changeset/cold-emus-arrive.md delete mode 100644 .changeset/custom-changelog-generator.js create mode 100644 .changeset/lucky-fireants-design.md create mode 100644 .changeset/spotty-pigs-beg.md create mode 100644 .changeset/stale-spoons-join.md create mode 100644 .changeset/unlucky-tables-carry.md create mode 100644 .changeset/wicked-jobs-rest.md create mode 100644 .gitmodules delete mode 120000 bin/.zig-0.11.0.pkg delete mode 120000 bin/zig delete mode 100644 crates/codegen/runtime/cargo/build.rs rename crates/codegen/runtime/cargo/{ => crate}/Cargo.toml (64%) create mode 100644 crates/codegen/runtime/cargo/crate/build.rs create mode 100644 crates/codegen/runtime/cargo/crate/src/lib.rs rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/bindings/binding_rules.rs.jinja2 (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/bindings/generated/binding_rules.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/bindings/mod.rs (100%) create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/edge_label.rs.jinja2 create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/edge_label.rs create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/lexical_context.rs create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/nonterminal_kind.rs create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/terminal_kind.rs create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/lexical_context.rs.jinja2 rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/cst/mod.rs (79%) create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/nonterminal_kind.rs.jinja2 create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/cst/terminal_kind.rs.jinja2 rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/diagnostic/mod.rs (95%) create mode 100644 crates/codegen/runtime/cargo/crate/src/runtime/mod.rs rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/generated/parser.rs (54%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/lexer/mod.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/mod.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parse_error.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parse_output.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser.rs.jinja2 (84%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/choice_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/context.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/mod.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/optional_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/parser_function.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/parser_result.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/precedence_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/recovery.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/repetition_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/separated_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/parser_support/sequence_helper.rs (100%) rename crates/codegen/runtime/cargo/{ => crate}/src/runtime/parser/scanner_macros/mod.rs (100%) delete mode 100644 crates/codegen/runtime/cargo/src/lib.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/cst/generated/kinds.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/cst/kinds.rs.jinja2 delete mode 100644 crates/codegen/runtime/cargo/src/runtime/mod.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/diagnostic.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/mod.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_error.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_output.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/interface/_types.rs.jinja2 delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/interface/diagnostic.wit.jinja2 delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_types.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/diagnostic.wit delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/mod.rs delete mode 100644 crates/codegen/runtime/cargo/src/runtime/wit/wrappers/diagnostic.rs create mode 100644 crates/codegen/runtime/cargo/wasm/Cargo.toml create mode 100644 crates/codegen/runtime/cargo/wasm/build.rs create mode 100644 crates/codegen/runtime/cargo/wasm/src/lib.rs create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/bindings.rs.jinja2 create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/config.json.jinja2 create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/generated/bindings.rs create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/generated/config.json create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/interface/ast.wit.jinja2 rename crates/codegen/runtime/cargo/{src/runtime/wit => wasm/src/runtime}/interface/cst.wit.jinja2 (84%) create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/ast.wit rename crates/codegen/runtime/cargo/{src/runtime/wit => wasm/src/runtime}/interface/generated/cst.wit (82%) rename crates/{testlang/outputs/cargo/slang_testlang/src/generated/wit => codegen/runtime/cargo/wasm/src/runtime}/interface/generated/parser.wit (83%) rename crates/{testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_world.wit => codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit} (88%) rename crates/codegen/runtime/cargo/{src/runtime/wit => wasm/src/runtime}/interface/parser.wit.jinja2 (80%) rename crates/codegen/runtime/cargo/{src/runtime/wit/interface/_world.wit.jinja2 => wasm/src/runtime/interface/world.wit.jinja2} (78%) create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/mod.rs rename crates/codegen/runtime/cargo/{src/runtime/wit => wasm/src/runtime}/utils.rs (88%) create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/mod.rs create mode 100644 crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/selectors.rs.jinja2 rename crates/codegen/runtime/cargo/{src/runtime/wit/wrappers/cst.rs => wasm/src/runtime/wrappers/cst/mod.rs} (72%) rename crates/codegen/runtime/cargo/{src/runtime/wit => wasm/src/runtime}/wrappers/mod.rs (56%) rename crates/codegen/runtime/cargo/{src/runtime/wit/wrappers/parser.rs => wasm/src/runtime/wrappers/parser/mod.rs} (51%) delete mode 100644 crates/codegen/runtime/node_addon/Cargo.toml delete mode 100644 crates/codegen/runtime/node_addon/build.rs delete mode 100644 crates/codegen/runtime/npm/build.rs delete mode 100644 crates/codegen/runtime/npm/package.json create mode 100644 crates/codegen/runtime/npm/package/.gitignore rename crates/codegen/runtime/npm/{ => package}/CHANGELOG.md (100%) rename crates/codegen/runtime/npm/{ => package}/Cargo.toml (80%) rename crates/codegen/runtime/npm/{ => package}/LICENSE (100%) rename crates/codegen/runtime/npm/{ => package}/README.md (100%) create mode 100644 crates/codegen/runtime/npm/package/build.rs create mode 100644 crates/codegen/runtime/npm/package/package.json rename crates/codegen/runtime/npm/{ => package}/src/lib.rs (100%) rename crates/codegen/runtime/npm/{src/runtime/ast/generated/ast_types.ts => package/src/runtime/ast/generated/nodes.mts} (100%) create mode 100644 crates/codegen/runtime/npm/package/src/runtime/ast/index.mts rename crates/codegen/runtime/npm/{src/runtime/ast/ast_types.ts.jinja2 => package/src/runtime/ast/nodes.mts.jinja2} (84%) create mode 100644 crates/codegen/runtime/npm/package/src/runtime/cst/index.mts create mode 100644 crates/codegen/runtime/npm/package/src/runtime/index.mts rename crates/codegen/runtime/npm/{src/runtime/parser/index.ts => package/src/runtime/parser/index.mts} (55%) create mode 100644 crates/codegen/runtime/npm/package/tsconfig.json create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/codegen_runtime_cargo_wasm.component.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts rename crates/{solidity/outputs/npm/package/src/generated/ast/index.ts => codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts} (55%) create mode 100644 crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts create mode 100644 crates/codegen/runtime/npm/package/wasm/index.mts delete mode 100644 crates/codegen/runtime/npm/src/runtime/ast/index.ts delete mode 100644 crates/codegen/runtime/npm/src/runtime/cst/index.ts delete mode 100644 crates/codegen/runtime/npm/src/runtime/diagnostic/index.ts delete mode 100644 crates/codegen/runtime/npm/src/runtime/index.ts delete mode 100644 crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts delete mode 100644 crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.js delete mode 100644 crates/codegen/runtime/npm/tsconfig.json delete mode 100644 crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 delete mode 100644 crates/infra/cli/src/toolchains/napi/bindings/index.js.jinja2 delete mode 100644 crates/infra/cli/src/toolchains/napi/cli.rs delete mode 100644 crates/infra/cli/src/toolchains/napi/compiler.rs delete mode 100644 crates/infra/cli/src/toolchains/napi/config.rs delete mode 100644 crates/infra/cli/src/toolchains/napi/glibc.rs delete mode 100644 crates/infra/cli/src/toolchains/napi/mod.rs delete mode 100644 crates/infra/cli/src/toolchains/napi/resolver.rs create mode 100644 crates/infra/cli/src/toolchains/npm/mod.rs create mode 100644 crates/infra/cli/src/toolchains/wasm/mod.rs rename crates/solidity/outputs/cargo/{slang_solidity => cli}/CHANGELOG.md (100%) rename crates/solidity/outputs/cargo/{slang_solidity_cli => cli}/Cargo.toml (83%) rename crates/solidity/outputs/cargo/{slang_solidity => cli}/LICENSE (100%) rename crates/solidity/outputs/cargo/{slang_solidity_cli => cli}/README.md (100%) rename crates/{codegen/runtime/cargo/src/runtime/cli/mod.rs => solidity/outputs/cargo/cli/src/main.rs} (88%) rename crates/{codegen/runtime/cargo/src/runtime/cli/commands => solidity/outputs/cargo/cli/src}/parse.rs (91%) rename crates/solidity/outputs/cargo/{slang_solidity_cli => crate}/CHANGELOG.md (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/Cargo.toml (82%) rename crates/solidity/outputs/cargo/{slang_solidity_cli => crate}/LICENSE (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/README.md (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/build.rs (61%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/generated/public_api.txt (99%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/bindings/generated/binding_rules.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/bindings/mod.rs (100%) create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs create mode 100644 crates/solidity/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs rename crates/{testlang/outputs/cargo/slang_testlang => solidity/outputs/cargo/crate}/src/generated/cst/mod.rs (80%) rename crates/{testlang/outputs/cargo/slang_testlang => solidity/outputs/cargo/crate}/src/generated/diagnostic/mod.rs (96%) rename crates/{testlang/outputs/cargo/slang_testlang => solidity/outputs/cargo/crate}/src/generated/mod.rs (52%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/generated/parser.rs (99%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/lexer/mod.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/mod.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parse_error.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parse_output.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/choice_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/context.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/mod.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/optional_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/parser_function.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/parser_result.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/precedence_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/recovery.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/repetition_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/separated_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/parser_support/sequence_helper.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/generated/parser/scanner_macros/mod.rs (100%) rename crates/solidity/outputs/cargo/{slang_solidity => crate}/src/lib.rs (100%) delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/parse.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/generated/kinds.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/mod.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_error.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_output.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_types.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/diagnostic.wit delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/mod.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/diagnostic.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity_cli/src/main.rs delete mode 100644 crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml delete mode 100644 crates/solidity/outputs/cargo/slang_solidity_node_addon/build.rs create mode 100644 crates/solidity/outputs/cargo/wasm/Cargo.toml create mode 100644 crates/solidity/outputs/cargo/wasm/build.rs create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/generated/bindings.rs create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/generated/config.json create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/ast.wit rename crates/solidity/outputs/cargo/{slang_solidity/src/generated/wit => wasm/src/generated}/interface/generated/cst.wit (97%) rename crates/{codegen/runtime/cargo/src/runtime/wit => solidity/outputs/cargo/wasm/src/generated}/interface/generated/parser.wit (83%) rename crates/{codegen/runtime/cargo/src/runtime/wit/interface/generated/_world.wit => solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit} (88%) create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/mod.rs rename crates/{testlang/outputs/cargo/slang_testlang/src/generated/wit => solidity/outputs/cargo/wasm/src/generated}/utils.rs (88%) create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs create mode 100644 crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs rename crates/{testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/cst.rs => solidity/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs} (73%) rename crates/solidity/outputs/cargo/{slang_solidity/src/generated/wit => wasm/src/generated}/wrappers/mod.rs (87%) rename crates/solidity/outputs/cargo/{slang_solidity/src/generated/wit/wrappers/parser.rs => wasm/src/generated/wrappers/parser/mod.rs} (53%) create mode 100644 crates/solidity/outputs/cargo/wasm/src/lib.rs create mode 100644 crates/solidity/outputs/npm/package/.gitignore create mode 100644 crates/solidity/outputs/npm/package/.npmignore delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-arm64/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-arm64/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-arm64/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-x64/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-x64/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/darwin-x64/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-musl/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-musl/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/linux-x64-musl/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/package.json delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/CHANGELOG.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/README.md delete mode 100644 crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/package.json rename crates/solidity/outputs/npm/package/src/generated/ast/generated/{ast_types.ts => nodes.mts} (84%) rename crates/solidity/outputs/{cargo/slang_solidity/src/generated/cli/commands/mod.rs => npm/package/src/generated/ast/index.mts} (70%) create mode 100644 crates/solidity/outputs/npm/package/src/generated/cst/index.mts delete mode 100644 crates/solidity/outputs/npm/package/src/generated/cst/index.ts delete mode 100644 crates/solidity/outputs/npm/package/src/generated/diagnostic/index.ts create mode 100644 crates/solidity/outputs/npm/package/src/generated/index.mts delete mode 100644 crates/solidity/outputs/npm/package/src/generated/index.ts delete mode 100644 crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts delete mode 100644 crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.js rename crates/{testlang/outputs/npm/package/src/generated/parser/index.ts => solidity/outputs/npm/package/src/generated/parser/index.mts} (62%) create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/generated/solidity_cargo_wasm.component.d.ts create mode 100644 crates/solidity/outputs/npm/package/wasm/index.mts create mode 100644 crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts delete mode 100644 crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts rename crates/solidity/outputs/npm/tests/src/doc-examples/{using-the-ast.ts => using-the-ast.mts} (63%) rename crates/solidity/outputs/npm/tests/src/doc-examples/{using-the-cursor.ts => using-the-cursor.mts} (71%) create mode 100644 crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts delete mode 100644 crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts create mode 100644 crates/solidity/outputs/npm/tests/src/utils/files.mts delete mode 100644 crates/solidity/outputs/npm/tests/src/utils/files.ts rename crates/testlang/outputs/cargo/{slang_testlang => crate}/Cargo.toml (68%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/build.rs (53%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/bindings/generated/binding_rules.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/bindings/mod.rs (100%) create mode 100644 crates/testlang/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs create mode 100644 crates/testlang/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs create mode 100644 crates/testlang/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs create mode 100644 crates/testlang/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs rename crates/{solidity/outputs/cargo/slang_solidity => testlang/outputs/cargo/crate}/src/generated/cst/mod.rs (80%) rename crates/{solidity/outputs/cargo/slang_solidity => testlang/outputs/cargo/crate}/src/generated/diagnostic/mod.rs (96%) rename crates/{solidity/outputs/cargo/slang_solidity => testlang/outputs/cargo/crate}/src/generated/mod.rs (52%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/generated/parser.rs (93%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/lexer/mod.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/mod.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parse_error.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parse_output.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/choice_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/context.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/mod.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/optional_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/parser_function.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/parser_result.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/precedence_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/recovery.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/repetition_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/separated_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/parser_support/sequence_helper.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/generated/parser/scanner_macros/mod.rs (100%) rename crates/testlang/outputs/cargo/{slang_testlang => crate}/src/lib.rs (100%) delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/parse.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/generated/kinds.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/mod.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_error.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_output.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_types.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/diagnostic.wit delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/mod.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/diagnostic.rs delete mode 100644 crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml delete mode 100644 crates/testlang/outputs/cargo/slang_testlang_node_addon/build.rs create mode 100644 crates/testlang/outputs/cargo/wasm/Cargo.toml create mode 100644 crates/testlang/outputs/cargo/wasm/build.rs create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/generated/bindings.rs create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/generated/config.json create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/ast.wit rename crates/testlang/outputs/cargo/{slang_testlang/src/generated/wit => wasm/src/generated}/interface/generated/cst.wit (85%) rename crates/{solidity/outputs/cargo/slang_solidity/src/generated/wit => testlang/outputs/cargo/wasm/src/generated}/interface/generated/parser.wit (83%) rename crates/{solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_world.wit => testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit} (88%) create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/mod.rs rename crates/{solidity/outputs/cargo/slang_solidity/src/generated/wit => testlang/outputs/cargo/wasm/src/generated}/utils.rs (88%) create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs create mode 100644 crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs rename crates/{solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/cst.rs => testlang/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs} (73%) rename crates/testlang/outputs/cargo/{slang_testlang/src/generated/wit => wasm/src/generated}/wrappers/mod.rs (87%) rename crates/testlang/outputs/cargo/{slang_testlang/src/generated/wit/wrappers/parser.rs => wasm/src/generated/wrappers/parser/mod.rs} (53%) create mode 100644 crates/testlang/outputs/cargo/wasm/src/lib.rs create mode 100644 crates/testlang/outputs/npm/package/.gitignore rename crates/testlang/outputs/npm/package/src/generated/ast/generated/{ast_types.ts => nodes.mts} (81%) rename crates/testlang/outputs/{cargo/slang_testlang/src/generated/cli/commands/mod.rs => npm/package/src/generated/ast/index.mts} (70%) delete mode 100644 crates/testlang/outputs/npm/package/src/generated/ast/index.ts create mode 100644 crates/testlang/outputs/npm/package/src/generated/cst/index.mts delete mode 100644 crates/testlang/outputs/npm/package/src/generated/cst/index.ts delete mode 100644 crates/testlang/outputs/npm/package/src/generated/diagnostic/index.ts create mode 100644 crates/testlang/outputs/npm/package/src/generated/index.mts delete mode 100644 crates/testlang/outputs/npm/package/src/generated/index.ts delete mode 100644 crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts delete mode 100644 crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.js rename crates/{solidity/outputs/npm/package/src/generated/parser/index.ts => testlang/outputs/npm/package/src/generated/parser/index.mts} (62%) create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/generated/testlang_cargo_wasm.component.d.ts create mode 100644 crates/testlang/outputs/npm/package/wasm/index.mts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/ast.ts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/ast/ast.mts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst-output.ts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst/cursor.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst/nodes.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst/query.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/cst/terminal-kind-extensions.mts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/errors.ts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/parser/parse-error.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/parser/parse.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/parser/root-kind.mts create mode 100644 crates/testlang/outputs/npm/tests/src/tests/parser/versions.mts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/public-api.ts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/query.ts delete mode 100644 crates/testlang/outputs/npm/tests/src/tests/versions.ts delete mode 100644 crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts delete mode 100644 crates/testlang/outputs/npm/tests/src/utils/files.ts create mode 160000 submodules/jco diff --git a/.changeset/calm-ghosts-melt.md b/.changeset/calm-ghosts-melt.md new file mode 100644 index 0000000000..a2419638c5 --- /dev/null +++ b/.changeset/calm-ghosts-melt.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +migrate NAPI front-end to WASM and ESM diff --git a/.changeset/cold-emus-arrive.md b/.changeset/cold-emus-arrive.md new file mode 100644 index 0000000000..020b8bcc64 --- /dev/null +++ b/.changeset/cold-emus-arrive.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +add `TerminalKindExtensions.is_valid()` API to distinguish correctly-parsed and erroneous nodes diff --git a/.changeset/config.json b/.changeset/config.json index 031aef9b1a..806c441b90 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -2,6 +2,5 @@ "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", "access": "public", "baseBranch": "main", - "changelog": ["./custom-changelog-generator.js", { "repo": "NomicFoundation/slang" }], - "fixed": [["@nomicfoundation/slang", "@nomicfoundation/slang-*"]] + "changelog": ["@changesets/changelog-github", { "repo": "NomicFoundation/slang" }] } diff --git a/.changeset/custom-changelog-generator.js b/.changeset/custom-changelog-generator.js deleted file mode 100644 index 6f5b601d26..0000000000 --- a/.changeset/custom-changelog-generator.js +++ /dev/null @@ -1,14 +0,0 @@ -const { default: original } = require("@changesets/changelog-github"); - -module.exports = { - getDependencyReleaseLine: (changesets, dependenciesUpdated, options) => { - // We don't want to embed NAPI dependency updates (always synced): - dependenciesUpdated = []; - - return original.getDependencyReleaseLine(changesets, dependenciesUpdated, options); - }, - - getReleaseLine: (changeset, type, options) => { - return original.getReleaseLine(changeset, type, options); - }, -}; diff --git a/.changeset/lucky-fireants-design.md b/.changeset/lucky-fireants-design.md new file mode 100644 index 0000000000..8e22911e15 --- /dev/null +++ b/.changeset/lucky-fireants-design.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": patch +--- + +change `Parser::new()` constructor to `Parser::create()` static method. diff --git a/.changeset/spotty-pigs-beg.md b/.changeset/spotty-pigs-beg.md new file mode 100644 index 0000000000..a54ed36d89 --- /dev/null +++ b/.changeset/spotty-pigs-beg.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +unify API methods on `TerminalNode` and `NonTerminalNode`, and add type assertions and guards to both types diff --git a/.changeset/stale-spoons-join.md b/.changeset/stale-spoons-join.md new file mode 100644 index 0000000000..61c5d674d6 --- /dev/null +++ b/.changeset/stale-spoons-join.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +expose edges and edge labels on CST nodes via `Node.children()` method. This allows distinguishing between children of the same node based on their label/role in the parent, even if they have the same kind. diff --git a/.changeset/unlucky-tables-carry.md b/.changeset/unlucky-tables-carry.md new file mode 100644 index 0000000000..bb81726c55 --- /dev/null +++ b/.changeset/unlucky-tables-carry.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +add `TerminalNode.id` and `Nonterminal.id` properties to get a numeric ID that can be used in indexing/comparison at runtime. diff --git a/.changeset/wicked-jobs-rest.md b/.changeset/wicked-jobs-rest.md new file mode 100644 index 0000000000..861406ee31 --- /dev/null +++ b/.changeset/wicked-jobs-rest.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/slang": minor +--- + +add `TerminalKindExtensions.is_trivia()` API to distinguish between trivia nodes and other contentful nodes diff --git a/.cspell.json b/.cspell.json index 05c4f7b4ba..e2acc93fe0 100644 --- a/.cspell.json +++ b/.cspell.json @@ -2,11 +2,12 @@ "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/v5.19.2/cspell.schema.json", "language": "en-US", "files": ["**/*.md"], - "ignorePaths": ["**/generated/**", "CHANGELOG.md"], + "ignorePaths": ["submodules/**", "**/generated/**", "CHANGELOG.md"], "ignoreWords": [ // Alphabetically sorted list of "allowed" words to ignore: "abicoder", "codegen", + "contentful", "devcontainer", "doxygen", "ebnf", diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..1b83970dcb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "submodules/jco"] + path = "submodules/jco" + url = "https://github.com/NomicFoundation/jco" + branch = "nomic-enhancements-release" diff --git a/.prettierignore b/.prettierignore index 785d67c0f4..cf423475ea 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,9 @@ # Scripts controlled by Hermit: bin/ +# Git Submodules +submodules/ + # Ember Templates documentation/overrides/**/*.html @@ -11,6 +14,9 @@ documentation/overrides/**/*.html **/.hermit/ **/node_modules/ +# Generated WASM bindings +**/wasm/generated/*.js + # Generated Artifacts **/target/ **/Pipfile.lock diff --git a/.vscode/settings.json b/.vscode/settings.json index ee213e90ee..b737e97921 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,7 @@ "editor.rulers": [120], "files.associations": { "**/documentation/overrides/**/*.html": "jinja-html", - "*.ts.jinja2": "jinja-js", // until 'jinja-ts' is released: https://github.com/samuelcolvin/jinjahtml-vscode/pull/148 + "*.{ts,mts}.jinja2": "jinja-js", // until 'jinja-ts' is released: https://github.com/samuelcolvin/jinjahtml-vscode/pull/148 "*.wit.jinja2": "wai" }, "editor.unicodeHighlight.allowedCharacters": { diff --git a/Cargo.lock b/Cargo.lock index 658f3d24a8..66609041d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,22 +448,33 @@ dependencies = [ ] [[package]] -name = "codegen_runtime_cargo" +name = "codegen_runtime_cargo_crate" version = "0.17.0" dependencies = [ "anyhow", "ariadne", - "clap", "codegen_runtime_generator", + "infra_utils", "metaslang_bindings", "metaslang_cst", - "paste", "semver", "serde", - "serde_json", "strum", "strum_macros", "thiserror", +] + +[[package]] +name = "codegen_runtime_cargo_wasm" +version = "0.17.0" +dependencies = [ + "anyhow", + "codegen_runtime_cargo_crate", + "codegen_runtime_generator", + "infra_utils", + "paste", + "semver", + "serde_json", "wit-bindgen", ] @@ -486,27 +497,12 @@ dependencies = [ ] [[package]] -name = "codegen_runtime_node_addon" -version = "0.17.0" -dependencies = [ - "metaslang_cst", - "napi", - "napi-build", - "napi-derive", - "semver", - "serde", - "serde_json", - "strum", - "strum_macros", - "thiserror", -] - -[[package]] -name = "codegen_runtime_npm" +name = "codegen_runtime_npm_package" version = "0.17.0" dependencies = [ "anyhow", "codegen_runtime_generator", + "infra_utils", ] [[package]] @@ -571,15 +567,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation" version = "0.9.3" @@ -648,16 +635,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctor" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" -dependencies = [ - "quote", - "syn 2.0.79", -] - [[package]] name = "darling" version = "0.20.9" @@ -1262,14 +1239,12 @@ dependencies = [ "infra_utils", "itertools 0.13.0", "markdown", - "regex", "semver", "serde", "serde_json", "strum", "strum_macros", "tempfile", - "tera", "toml", ] @@ -1366,16 +1341,6 @@ version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" -[[package]] -name = "libloading" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "libm" version = "0.2.7" @@ -1501,65 +1466,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "napi" -version = "2.16.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53575dfa17f208dd1ce3a2da2da4659aae393b256a472f2738a8586a6c4107fd" -dependencies = [ - "bitflags 2.5.0", - "ctor", - "napi-derive", - "napi-sys", - "once_cell", - "serde", - "serde_json", -] - -[[package]] -name = "napi-build" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" - -[[package]] -name = "napi-derive" -version = "2.16.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17435f7a00bfdab20b0c27d9c56f58f6499e418252253081bfff448099da31d1" -dependencies = [ - "cfg-if", - "convert_case", - "napi-derive-backend", - "proc-macro2", - "quote", - "syn 2.0.79", -] - -[[package]] -name = "napi-derive-backend" -version = "1.0.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "967c485e00f0bf3b1bdbe510a38a4606919cf1d34d9a37ad41f25a81aa077abe" -dependencies = [ - "convert_case", - "once_cell", - "proc-macro2", - "quote", - "regex", - "semver", - "syn 2.0.79", -] - -[[package]] -name = "napi-sys" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427802e8ec3a734331fec1035594a210ce1ff4dc5bc1950530920ab717964ea3" -dependencies = [ - "libloading", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -2302,43 +2208,26 @@ version = "0.17.0" dependencies = [ "anyhow", "ariadne", - "clap", "codegen_runtime_generator", "infra_utils", "metaslang_bindings", "metaslang_cst", - "paste", "semver", "serde", - "serde_json", "solidity_language", "strum", "strum_macros", "thiserror", - "wit-bindgen", ] [[package]] name = "slang_solidity_cli" version = "0.17.0" dependencies = [ - "slang_solidity", -] - -[[package]] -name = "slang_solidity_node_addon" -version = "0.17.0" -dependencies = [ - "metaslang_cst", - "napi", - "napi-build", - "napi-derive", + "clap", "semver", - "serde", "serde_json", - "strum", - "strum_macros", - "thiserror", + "slang_solidity", ] [[package]] @@ -2347,36 +2236,16 @@ version = "0.17.0" dependencies = [ "anyhow", "ariadne", - "clap", "codegen_runtime_generator", "infra_utils", "metaslang_bindings", "metaslang_cst", - "paste", "semver", "serde", - "serde_json", "strum", "strum_macros", "testlang_language", "thiserror", - "wit-bindgen", -] - -[[package]] -name = "slang_testlang_node_addon" -version = "0.17.0" -dependencies = [ - "metaslang_cst", - "napi", - "napi-build", - "napi-derive", - "semver", - "serde", - "serde_json", - "strum", - "strum_macros", - "thiserror", ] [[package]] @@ -2426,6 +2295,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "solidity_cargo_wasm" +version = "0.17.0" +dependencies = [ + "anyhow", + "codegen_runtime_generator", + "infra_utils", + "paste", + "semver", + "serde_json", + "slang_solidity", + "solidity_language", + "wit-bindgen", +] + [[package]] name = "solidity_language" version = "0.17.0" @@ -2708,6 +2592,21 @@ dependencies = [ "slang_testlang", ] +[[package]] +name = "testlang_cargo_wasm" +version = "0.17.0" +dependencies = [ + "anyhow", + "codegen_runtime_generator", + "infra_utils", + "paste", + "semver", + "serde_json", + "slang_testlang", + "testlang_language", + "wit-bindgen", +] + [[package]] name = "testlang_language" version = "0.17.0" diff --git a/Cargo.toml b/Cargo.toml index cd53c80837..1282b7e021 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ members = [ "crates/codegen/language/internal_macros", "crates/codegen/language/macros", "crates/codegen/language/tests", - "crates/codegen/runtime/cargo", + "crates/codegen/runtime/cargo/crate", + "crates/codegen/runtime/cargo/wasm", "crates/codegen/runtime/generator", - "crates/codegen/runtime/node_addon", - "crates/codegen/runtime/npm", + "crates/codegen/runtime/npm/package", "crates/codegen/spec", "crates/codegen/testing", @@ -27,10 +27,10 @@ members = [ "crates/metaslang/graph_builder", "crates/solidity/inputs/language", - "crates/solidity/outputs/cargo/slang_solidity_cli", - "crates/solidity/outputs/cargo/slang_solidity_node_addon", - "crates/solidity/outputs/cargo/slang_solidity", + "crates/solidity/outputs/cargo/cli", + "crates/solidity/outputs/cargo/crate", "crates/solidity/outputs/cargo/tests", + "crates/solidity/outputs/cargo/wasm", "crates/solidity/outputs/npm/package", "crates/solidity/outputs/spec", "crates/solidity/testing/perf", @@ -39,9 +39,9 @@ members = [ "crates/solidity/testing/solc", "crates/testlang/inputs/language", - "crates/testlang/outputs/cargo/slang_testlang_node_addon", - "crates/testlang/outputs/cargo/slang_testlang", + "crates/testlang/outputs/cargo/crate", "crates/testlang/outputs/cargo/tests", + "crates/testlang/outputs/cargo/wasm", "crates/testlang/outputs/npm/package", ] @@ -54,10 +54,10 @@ codegen_language_definition = { path = "crates/codegen/language/definition", ver codegen_language_internal_macros = { path = "crates/codegen/language/internal_macros", version = "0.17.0" } codegen_language_macros = { path = "crates/codegen/language/macros", version = "0.17.0" } codegen_language_tests = { path = "crates/codegen/language/tests", version = "0.17.0" } -codegen_runtime_cargo = { path = "crates/codegen/runtime/cargo", version = "0.17.0" } +codegen_runtime_cargo_crate = { path = "crates/codegen/runtime/cargo/crate", version = "0.17.0" } +codegen_runtime_cargo_wasm = { path = "crates/codegen/runtime/cargo/wasm", version = "0.17.0" } codegen_runtime_generator = { path = "crates/codegen/runtime/generator", version = "0.17.0" } -codegen_runtime_node_addon = { path = "crates/codegen/runtime/node_addon", version = "0.17.0" } -codegen_runtime_npm = { path = "crates/codegen/runtime/npm", version = "0.17.0" } +codegen_runtime_npm_package = { path = "crates/codegen/runtime/npm/package", version = "0.17.0" } codegen_spec = { path = "crates/codegen/spec", version = "0.17.0" } codegen_testing = { path = "crates/codegen/testing", version = "0.17.0" } @@ -68,10 +68,10 @@ metaslang_bindings = { path = "crates/metaslang/bindings", version = "0.17.0" } metaslang_graph_builder = { path = "crates/metaslang/graph_builder", version = "0.17.0" } metaslang_cst = { path = "crates/metaslang/cst", version = "0.17.0" } -slang_solidity = { path = "crates/solidity/outputs/cargo/slang_solidity", version = "0.17.0" } -slang_solidity_cli = { path = "crates/solidity/outputs/cargo/slang_solidity_cli", version = "0.17.0" } -slang_solidity_node_addon = { path = "crates/solidity/outputs/cargo/slang_solidity_node_addon", version = "0.17.0" } +slang_solidity = { path = "crates/solidity/outputs/cargo/crate", version = "0.17.0" } +slang_solidity_cli = { path = "crates/solidity/outputs/cargo/cli", version = "0.17.0" } solidity_cargo_tests = { path = "crates/solidity/outputs/cargo/tests", version = "0.17.0" } +solidity_cargo_wasm = { path = "crates/solidity/outputs/cargo/wasm", version = "0.17.0" } solidity_language = { path = "crates/solidity/inputs/language", version = "0.17.0" } solidity_npm_package = { path = "crates/solidity/outputs/npm/package", version = "0.17.0" } solidity_spec = { path = "crates/solidity/outputs/spec", version = "0.17.0" } @@ -80,9 +80,9 @@ solidity_testing_sanctuary = { path = "crates/solidity/testing/sanctuary", versi solidity_testing_snapshots = { path = "crates/solidity/testing/snapshots", version = "0.17.0" } solidity_testing_solc = { path = "crates/solidity/testing/solc", version = "0.17.0" } -slang_testlang = { path = "crates/testlang/outputs/cargo/slang_testlang", version = "0.17.0" } -slang_testlang_node_addon = { path = "crates/testlang/outputs/cargo/slang_testlang_node_addon", version = "0.17.0" } +slang_testlang = { path = "crates/testlang/outputs/cargo/crate", version = "0.17.0" } testlang_cargo_tests = { path = "crates/testlang/outputs/cargo/tests", version = "0.17.0" } +testlang_cargo_wasm = { path = "crates/testlang/outputs/cargo/wasm", version = "0.17.0" } testlang_language = { path = "crates/testlang/inputs/language", version = "0.17.0" } testlang_npm_package = { path = "crates/testlang/outputs/npm/package", version = "0.17.0" } @@ -114,9 +114,6 @@ Inflector = { version = "0.11.4" } itertools = { version = "0.13.0" } log = { version = "0.4.22" } markdown = { version = "0.3.0" } -napi = { version = "2.16.11", features = ["compat-mode", "napi8", "serde-json"] } -napi-build = { version = "2.1.3" } -napi-derive = { version = "2.16.12" } nom = { version = "7.1.3" } num-format = { version = "0.4.4" } once_cell = { version = "1.19.0" } @@ -154,6 +151,7 @@ thiserror = { version = "1.0.64" } toml = { version = "0.8.19" } trybuild = { version = "1.0.99" } url = { version = "2.4.1", features = ["serde"] } +wasm-tools = { version = "1.216.0" } wit-bindgen = { version = "0.30.0" } [workspace.lints.rust] diff --git a/bin/.zig-0.11.0.pkg b/bin/.zig-0.11.0.pkg deleted file mode 120000 index 383f4511d4..0000000000 --- a/bin/.zig-0.11.0.pkg +++ /dev/null @@ -1 +0,0 @@ -hermit \ No newline at end of file diff --git a/bin/zig b/bin/zig deleted file mode 120000 index 46de30bb8d..0000000000 --- a/bin/zig +++ /dev/null @@ -1 +0,0 @@ -.zig-0.11.0.pkg \ No newline at end of file diff --git a/crates/codegen/runtime/cargo/build.rs b/crates/codegen/runtime/cargo/build.rs deleted file mode 100644 index 6ab086731c..0000000000 --- a/crates/codegen/runtime/cargo/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; - -fn main() -> Result<()> { - OutputLanguage::Cargo.generate_stubs() -} diff --git a/crates/codegen/runtime/cargo/Cargo.toml b/crates/codegen/runtime/cargo/crate/Cargo.toml similarity index 64% rename from crates/codegen/runtime/cargo/Cargo.toml rename to crates/codegen/runtime/cargo/crate/Cargo.toml index 1306f3a357..dea69d8bb6 100644 --- a/crates/codegen/runtime/cargo/Cargo.toml +++ b/crates/codegen/runtime/cargo/crate/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "codegen_runtime_cargo" +name = "codegen_runtime_cargo_crate" version.workspace = true rust-version.workspace = true edition.workspace = true @@ -11,27 +11,23 @@ description = "Cargo runtime copied over by codegen" [features] default = [] __experimental_bindings_api = ["dep:metaslang_bindings"] -__private_cli_execution = ["dep:ariadne", "dep:clap", "dep:serde_json"] -__private_testing_utils = ["dep:ariadne"] -__private_wit_bindings = ["dep:paste", "dep:wit-bindgen"] +__private_ariadne_errors = ["dep:ariadne"] +__private_testing_utils = [] [build-dependencies] anyhow = { workspace = true } +infra_utils = { workspace = true } codegen_runtime_generator = { workspace = true } [dependencies] ariadne = { workspace = true, optional = true } -clap = { workspace = true, optional = true } metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -paste = { workspace = true, optional = 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/codegen/runtime/cargo/crate/build.rs b/crates/codegen/runtime/cargo/crate/build.rs new file mode 100644 index 0000000000..b6b9997129 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/build.rs @@ -0,0 +1,9 @@ +use anyhow::Result; +use codegen_runtime_generator::RuntimeGenerator; +use infra_utils::cargo::CargoWorkspace; + +fn main() -> Result<()> { + let source_dir = CargoWorkspace::locate_source_crate("codegen_runtime_cargo_crate")?; + + RuntimeGenerator::generate_stubs(&source_dir) +} diff --git a/crates/codegen/runtime/cargo/crate/src/lib.rs b/crates/codegen/runtime/cargo/crate/src/lib.rs new file mode 100644 index 0000000000..115e9459b8 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/lib.rs @@ -0,0 +1,7 @@ +// Disable dead-code checking in this stubs crate, as they are not necissarily used in tests. +// The final code (generated in output crates) is checked for dead-code anyways. +#![allow(dead_code, unused_imports)] + +mod runtime; + +pub use runtime::*; diff --git a/crates/codegen/runtime/cargo/src/runtime/bindings/binding_rules.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/bindings/binding_rules.rs.jinja2 similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/bindings/binding_rules.rs.jinja2 rename to crates/codegen/runtime/cargo/crate/src/runtime/bindings/binding_rules.rs.jinja2 diff --git a/crates/codegen/runtime/cargo/src/runtime/bindings/generated/binding_rules.rs b/crates/codegen/runtime/cargo/crate/src/runtime/bindings/generated/binding_rules.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/bindings/generated/binding_rules.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/bindings/generated/binding_rules.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/bindings/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/edge_label.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/cst/edge_label.rs.jinja2 new file mode 100644 index 0000000000..44572d27d6 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/edge_label.rs.jinja2 @@ -0,0 +1,36 @@ +{# 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, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[strum(serialize_all = "snake_case")] +#[derive(Clone, Copy)] +pub enum EdgeLabel { + // Built-in: + {% for label in model.kinds.built_in_labels -%} + {{ label | pascal_case }}, + {%- endfor %} + + // Generated: + {% if rendering_in_stubs -%} + Stub1, + Stub2, + Stub3, + {%- else -%} + {% for variant in model.kinds.labels -%} + {{ variant | pascal_case }}, + {%- endfor -%} + {%- endif -%} +} + +impl crate::cst::EdgeLabelExtensions for EdgeLabel {} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/edge_label.rs b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/edge_label.rs new file mode 100644 index 0000000000..d8e1389451 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/edge_label.rs @@ -0,0 +1,36 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[strum(serialize_all = "snake_case")] +#[derive(Clone, Copy)] +pub enum EdgeLabel { + // Built-in: + Item, + Variant, + Separator, + Operand, + LeftOperand, + RightOperand, + LeadingTrivia, + TrailingTrivia, + + // Generated: + Stub1, + Stub2, + Stub3, +} + +impl crate::cst::EdgeLabelExtensions for EdgeLabel {} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/lexical_context.rs b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/lexical_context.rs new file mode 100644 index 0000000000..c591b3a856 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/lexical_context.rs @@ -0,0 +1,20 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +/// The lexical context of the scanner. + +#[repr(u8)] +#[derive(strum_macros::FromRepr, Clone, Copy)] +pub(crate) enum LexicalContext { + Stub1, + Stub2, + Stub3, +} + +/// Marker trait for type-level [`LexicalContext`] variants. +pub(crate) trait IsLexicalContext { + /// Returns a run-time [`LexicalContext`] value. + fn value() -> LexicalContext; +} + +#[allow(non_snake_case)] +pub(crate) mod LexicalContextType {} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/nonterminal_kind.rs b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/nonterminal_kind.rs new file mode 100644 index 0000000000..e10bf380b8 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/nonterminal_kind.rs @@ -0,0 +1,25 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +pub enum NonterminalKind { + Stub1, + Stub2, + Stub3, +} + +impl crate::cst::NonterminalKindExtensions for NonterminalKind {} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/terminal_kind.rs b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/terminal_kind.rs new file mode 100644 index 0000000000..9bb18800a7 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/generated/terminal_kind.rs @@ -0,0 +1,39 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +#[allow(clippy::upper_case_acronyms)] +pub enum TerminalKind { + // Built-in: + UNRECOGNIZED, + MISSING, + + // Generated: + Stub1, + Stub2, + Stub3, +} + +impl crate::cst::TerminalKindExtensions for TerminalKind { + fn is_trivia(&self) -> bool { + false + } + + fn is_valid(&self) -> bool { + !matches!(self, Self::UNRECOGNIZED | Self::MISSING) + } +} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/lexical_context.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/cst/lexical_context.rs.jinja2 new file mode 100644 index 0000000000..56326a7a8f --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/lexical_context.rs.jinja2 @@ -0,0 +1,36 @@ +/// 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 -%} + Stub1, + Stub2, + Stub3, + {%- else -%} + {%- for context_name in model.kinds.lexical_contexts %} + {{ context_name }}, + {%- endfor %} + {%- endif -%} +} + +/// Marker trait for type-level [`LexicalContext`] variants. +pub(crate) trait IsLexicalContext { + /// Returns a run-time [`LexicalContext`] value. + fn value() -> LexicalContext; +} + +#[allow(non_snake_case)] +pub(crate) mod LexicalContextType { + {%- if not rendering_in_stubs -%} + {%- for context_name in model.kinds.lexical_contexts %} + pub struct {{ context_name }}; + + impl super::IsLexicalContext for {{ context_name }} { + fn value() -> super::LexicalContext { + super::LexicalContext::{{ context_name }} + } + } + {%- endfor %} + {%- endif -%} +} diff --git a/crates/codegen/runtime/cargo/src/runtime/cst/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/cst/mod.rs similarity index 79% rename from crates/codegen/runtime/cargo/src/runtime/cst/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/cst/mod.rs index c20c4ba287..e69fc2039f 100644 --- a/crates/codegen/runtime/cargo/src/runtime/cst/mod.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/mod.rs @@ -1,11 +1,19 @@ -#[path = "generated/kinds.rs"] -mod kinds; +#[path = "generated/edge_label.rs"] +mod edge_label; +#[path = "generated/lexical_context.rs"] +mod lexical_context; +#[path = "generated/nonterminal_kind.rs"] +mod nonterminal_kind; +#[path = "generated/terminal_kind.rs"] +mod terminal_kind; -pub use kinds::{EdgeLabel, NonterminalKind, TerminalKind}; -pub(crate) use kinds::{IsLexicalContext, LexicalContext, LexicalContextType}; +pub use edge_label::EdgeLabel; +pub(crate) use lexical_context::{IsLexicalContext, LexicalContext, LexicalContextType}; pub use metaslang_cst::kinds::{ EdgeLabelExtensions, NonterminalKindExtensions, TerminalKindExtensions, }; +pub use nonterminal_kind::NonterminalKind; +pub use terminal_kind::TerminalKind; // These derives are because default #[derive(...)] on a generic type implements only the trait // with default bounds also implied for the generic types as well, i.e. @@ -36,7 +44,8 @@ pub type Cursor = metaslang_cst::cursor::Cursor; pub type CursorWithEdges = metaslang_cst::cursor::CursorWithEdges; pub type Query = metaslang_cst::query::Query; +pub use metaslang_cst::query::QueryError; pub type QueryMatch = metaslang_cst::query::QueryMatch; pub type QueryMatchIterator = metaslang_cst::query::QueryMatchIterator; -pub use metaslang_cst::query::QueryError; + pub use metaslang_cst::text_index::{TextIndex, TextRange, TextRangeExtensions}; diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/nonterminal_kind.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/cst/nonterminal_kind.rs.jinja2 new file mode 100644 index 0000000000..532933d4cc --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/nonterminal_kind.rs.jinja2 @@ -0,0 +1,30 @@ +{# 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, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[derive(Clone, Copy)] +pub enum NonterminalKind { + {%- if rendering_in_stubs -%} + Stub1, + Stub2, + Stub3, + {%- else -%} + {%- for variant in model.kinds.nonterminal_kinds -%} + {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} + {{ variant }}, + {%- endfor -%} + {%- endif -%} +} + +impl crate::cst::NonterminalKindExtensions for NonterminalKind {} diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/cst/terminal_kind.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/cst/terminal_kind.rs.jinja2 new file mode 100644 index 0000000000..30b4512b88 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/cst/terminal_kind.rs.jinja2 @@ -0,0 +1,53 @@ +{# 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, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[derive(Clone, Copy)] +#[allow(clippy::upper_case_acronyms)] +pub enum TerminalKind { + // Built-in: + UNRECOGNIZED, + MISSING, + + // Generated: + {% if rendering_in_stubs -%} + Stub1, + Stub2, + Stub3, + {%- else -%} + {%- for variant in model.kinds.terminal_kinds -%} + {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} + {{ variant }}, + {%- endfor -%} + {%- endif -%} +} + +impl crate::cst::TerminalKindExtensions for TerminalKind { + fn is_trivia(&self) -> bool { + {%- if rendering_in_stubs -%} + false + {%- else -%} + matches!( + self, + {%- for variant in model.kinds.trivia_scanner_names -%} + | Self::{{ variant }} + {%- endfor -%} + ) + {%- endif -%} + } + + fn is_valid(&self) -> bool { + !matches!(self, Self::UNRECOGNIZED | Self::MISSING) + } +} diff --git a/crates/codegen/runtime/cargo/src/runtime/diagnostic/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/diagnostic/mod.rs similarity index 95% rename from crates/codegen/runtime/cargo/src/runtime/diagnostic/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/diagnostic/mod.rs index 5c1deb8e5d..0dc514a7d7 100644 --- a/crates/codegen/runtime/cargo/src/runtime/diagnostic/mod.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/diagnostic/mod.rs @@ -22,10 +22,7 @@ pub trait Diagnostic { fn message(&self) -> String; } -#[cfg(any( - feature = "__private_cli_execution", - feature = "__private_testing_utils" -))] +#[cfg(feature = "__private_ariadne_errors")] pub fn render(error: &D, source_id: &str, source: &str, with_color: bool) -> String { use ariadne::{Color, Config, Label, Report, ReportKind, Source}; diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/mod.rs new file mode 100644 index 0000000000..6856966831 --- /dev/null +++ b/crates/codegen/runtime/cargo/crate/src/runtime/mod.rs @@ -0,0 +1,5 @@ +#[cfg(feature = "__experimental_bindings_api")] +pub mod bindings; +pub mod cst; +pub mod diagnostic; +pub mod parser; diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/generated/parser.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/generated/parser.rs similarity index 54% rename from crates/codegen/runtime/cargo/src/runtime/parser/generated/parser.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/generated/parser.rs index d32764b71a..d155877f4a 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser/generated/parser.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/parser/generated/parser.rs @@ -10,16 +10,12 @@ unused_imports )] -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; use semver::Version; use crate::cst; use crate::cst::{ EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -#[cfg(feature = "__private_napi_interfaces")] -use crate::napi_interface::parser::ParseOutput as NAPIParseOutput; use crate::parser::lexer::{KeywordScan, Lexer, ScannedTerminal}; use crate::parser::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, @@ -33,26 +29,14 @@ use crate::parser::scanner_macros::{ use crate::parser::ParseOutput; #[derive(Debug)] -#[cfg_attr(feature = "__private_napi_interfaces", napi(namespace = "parser"))] pub struct Parser { - pub(crate) version: Version, + pub version: Version, } #[derive(thiserror::Error, Debug)] pub enum ParserInitializationError { #[error("Unsupported language version '{0}'.")] UnsupportedLanguageVersion(Version), - - #[cfg(feature = "__private_napi_interfaces")] - #[error("Invalid semantic version '{0}'.")] - InvalidSemanticVersion(String), -} - -#[cfg(feature = "__private_napi_interfaces")] -impl From for napi::Error { - fn from(value: ParserInitializationError) -> Self { - napi::Error::from_reason(value.to_string()) - } } impl Parser { @@ -60,7 +44,7 @@ impl Parser { pub const ROOT_KIND: NonterminalKind = NonterminalKind::Stub1; - pub fn new(version: Version) -> std::result::Result { + pub fn create(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { version }) } else { @@ -99,47 +83,3 @@ impl Lexer for Parser { unreachable!("Invoking next_terminal in stubs: {input:#?}") } } - -#[cfg(feature = "__private_napi_interfaces")] -// NAPI-exposed functions have to accept owned values. -#[allow(clippy::needless_pass_by_value)] -#[napi(namespace = "parser")] -impl Parser { - #[napi(constructor, catch_unwind)] - pub fn new_napi(version: String) -> std::result::Result { - let version = Version::parse(&version) - .map_err(|_| ParserInitializationError::InvalidSemanticVersion(version))?; - Self::new(version).map_err(|e| e.into()) - } - - #[napi(getter, js_name = "version", catch_unwind)] - pub fn version_napi(&self) -> String { - self.version.to_string() - } - - #[napi(js_name = "supportedVersions", catch_unwind)] - pub fn supported_versions_napi() -> Vec { - return Self::SUPPORTED_VERSIONS - .iter() - .map(|v| v.to_string()) - .collect(); - } - - #[napi( - js_name = "rootKind", - ts_return_type = "cst.NonterminalKind", - catch_unwind - )] - pub fn root_kind_napi() -> NonterminalKind { - Self::ROOT_KIND - } - - #[napi(js_name = "parse", ts_return_type = "parser.ParseOutput", catch_unwind)] - pub fn parse_napi( - &self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - input: String, - ) -> NAPIParseOutput { - self.parse(kind, input.as_str()).into() - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/lexer/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/lexer/mod.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/lexer/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/lexer/mod.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/mod.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/mod.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parse_error.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parse_error.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parse_error.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parse_error.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parse_output.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parse_output.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parse_output.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parse_output.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser.rs.jinja2 b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser.rs.jinja2 similarity index 84% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser.rs.jinja2 rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser.rs.jinja2 index 223e0b0ae0..a2c8b8cc2f 100644 --- a/crates/codegen/runtime/cargo/src/runtime/parser/parser.rs.jinja2 +++ b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser.rs.jinja2 @@ -9,8 +9,6 @@ )] use semver::Version; -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; use crate::cst; use crate::cst::{ @@ -26,12 +24,9 @@ use crate::parser::scanner_macros::{ scan_char_range, scan_chars, scan_choice, scan_keyword_choice, scan_none_of, scan_not_followed_by, scan_one_or_more, scan_optional, scan_sequence, scan_zero_or_more, }; -#[cfg(feature = "__private_napi_interfaces")] -use crate::napi_interface::parser::ParseOutput as NAPIParseOutput; use crate::parser::ParseOutput; #[derive(Debug)] -#[cfg_attr(feature = "__private_napi_interfaces", napi(namespace = "parser"))] pub struct Parser { {%- if not rendering_in_stubs -%} {%- for version in model.breaking_language_versions -%} @@ -42,24 +37,13 @@ pub struct Parser { {%- endfor -%} {%- endif -%} - pub(crate) version: Version, + pub version: Version, } #[derive(thiserror::Error, Debug)] pub enum ParserInitializationError { #[error("Unsupported language version '{0}'.")] UnsupportedLanguageVersion(Version), - - #[cfg(feature = "__private_napi_interfaces")] - #[error("Invalid semantic version '{0}'.")] - InvalidSemanticVersion(String), -} - -#[cfg(feature = "__private_napi_interfaces")] -impl From for napi::Error { - fn from(value: ParserInitializationError) -> Self { - napi::Error::from_reason(value.to_string()) - } } impl Parser { @@ -73,7 +57,7 @@ impl Parser { pub const ROOT_KIND: NonterminalKind = NonterminalKind::{{ model.kinds.root_kind }}; - pub fn new(version: Version) -> std::result::Result { + pub fn create(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { {%- if not rendering_in_stubs -%} @@ -278,41 +262,3 @@ impl Lexer for Parser { {%- endif -%} } } - -#[cfg(feature = "__private_napi_interfaces")] -// NAPI-exposed functions have to accept owned values. -#[allow(clippy::needless_pass_by_value)] -#[napi(namespace = "parser")] -impl Parser { - - #[napi(constructor, catch_unwind)] - pub fn new_napi(version: String) -> std::result::Result { - let version = Version::parse(&version).map_err(|_| ParserInitializationError::InvalidSemanticVersion(version))?; - Self::new(version).map_err(|e| e.into()) - } - - #[napi(getter, js_name = "version", catch_unwind)] - pub fn version_napi(&self) -> String { - self.version.to_string() - } - - #[napi(js_name = "supportedVersions", catch_unwind)] - pub fn supported_versions_napi() -> Vec { - return Self::SUPPORTED_VERSIONS.iter().map(|v| v.to_string()).collect(); - } - - #[napi(js_name = "rootKind", ts_return_type = "cst.NonterminalKind", catch_unwind)] - pub fn root_kind_napi() -> NonterminalKind { - Self::ROOT_KIND - } - - #[napi(js_name = "parse", ts_return_type = "parser.ParseOutput", catch_unwind)] - pub fn parse_napi( - &self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - input: String - ) -> NAPIParseOutput { - self.parse(kind, input.as_str()).into() - } - -} diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/choice_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/choice_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/choice_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/choice_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/context.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/context.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/context.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/context.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/mod.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/mod.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/optional_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/optional_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/optional_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/optional_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/parser_function.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/parser_function.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/parser_function.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/parser_function.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/parser_result.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/parser_result.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/parser_result.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/parser_result.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/precedence_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/precedence_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/precedence_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/precedence_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/recovery.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/recovery.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/recovery.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/recovery.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/repetition_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/repetition_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/repetition_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/repetition_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/separated_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/separated_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/separated_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/separated_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/parser_support/sequence_helper.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/sequence_helper.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/parser_support/sequence_helper.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/parser_support/sequence_helper.rs diff --git a/crates/codegen/runtime/cargo/src/runtime/parser/scanner_macros/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/parser/scanner_macros/mod.rs similarity index 100% rename from crates/codegen/runtime/cargo/src/runtime/parser/scanner_macros/mod.rs rename to crates/codegen/runtime/cargo/crate/src/runtime/parser/scanner_macros/mod.rs diff --git a/crates/codegen/runtime/cargo/src/lib.rs b/crates/codegen/runtime/cargo/src/lib.rs deleted file mode 100644 index 16f152c12c..0000000000 --- a/crates/codegen/runtime/cargo/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(dead_code)] - -mod runtime; - -pub use runtime::*; diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs b/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs deleted file mode 100644 index ea868482d6..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/cli/commands/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod parse; diff --git a/crates/codegen/runtime/cargo/src/runtime/cst/generated/kinds.rs b/crates/codegen/runtime/cargo/src/runtime/cst/generated/kinds.rs deleted file mode 100644 index 5d18c85967..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/cst/generated/kinds.rs +++ /dev/null @@ -1,124 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -pub enum NonterminalKind { - Stub1, - Stub2, - Stub3, -} - -impl crate::cst::NonterminalKindExtensions for NonterminalKind {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[strum(serialize_all = "snake_case")] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -pub enum EdgeLabel { - // Built-in: - Item, - Variant, - Separator, - Operand, - LeftOperand, - RightOperand, - LeadingTrivia, - TrailingTrivia, - - // Generated: - Stub1, - Stub2, - Stub3, -} - -impl crate::cst::EdgeLabelExtensions for EdgeLabel {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -#[allow(clippy::upper_case_acronyms)] -pub enum TerminalKind { - // Built-in: - UNRECOGNIZED, - MISSING, - - // Generated: - Stub1, - Stub2, - Stub3, -} - -impl crate::cst::TerminalKindExtensions for TerminalKind { - fn is_trivia(&self) -> bool { - false - } - - fn is_valid(&self) -> bool { - !matches!(self, Self::UNRECOGNIZED | Self::MISSING) - } -} - -/// 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, - Stub2, - Stub3, -} - -/// Marker trait for type-level [`LexicalContext`] variants. -pub(crate) trait IsLexicalContext { - /// Returns a run-time [`LexicalContext`] value. - fn value() -> LexicalContext; -} - -#[allow(non_snake_case)] -pub(crate) mod LexicalContextType {} diff --git a/crates/codegen/runtime/cargo/src/runtime/cst/kinds.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/cst/kinds.rs.jinja2 deleted file mode 100644 index cfb745198d..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/cst/kinds.rs.jinja2 +++ /dev/null @@ -1,164 +0,0 @@ -#[cfg(feature = "__private_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, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -pub enum NonterminalKind { - {%- if rendering_in_stubs -%} - Stub1, - Stub2, - Stub3, - {%- else -%} - {%- for variant in model.kinds.nonterminal_kinds -%} - {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} - {{ variant }}, - {%- endfor -%} - {%- endif -%} -} - -impl crate::cst::NonterminalKindExtensions 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, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[strum(serialize_all = "snake_case")] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -pub enum EdgeLabel { - // Built-in: - {% for label in model.kinds.built_in_labels -%} - {{ label | pascal_case }}, - {%- endfor %} - - // Generated: - {% if rendering_in_stubs -%} - Stub1, - Stub2, - Stub3, - {%- else -%} - {% for variant in model.kinds.labels -%} - {{ variant | pascal_case }}, - {%- endfor -%} - {%- endif -%} -} - -impl crate::cst::EdgeLabelExtensions 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, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -#[allow(clippy::upper_case_acronyms)] -pub enum TerminalKind { - // Built-in: - UNRECOGNIZED, - MISSING, - - // Generated: - {% if rendering_in_stubs -%} - Stub1, - Stub2, - Stub3, - {%- else -%} - {%- for variant in model.kinds.terminal_kinds -%} - {# variant.documentation | indent(prefix = "/// ", first = true, blank = true) #} - {{ variant }}, - {%- endfor -%} - {%- endif -%} -} - -impl crate::cst::TerminalKindExtensions for TerminalKind { - fn is_trivia(&self) -> bool { - {%- if rendering_in_stubs -%} - false - {%- else -%} - matches!( - self, - {%- for variant in model.kinds.trivia_scanner_names -%} - | Self::{{ variant }} - {%- endfor -%} - ) - {%- endif -%} - } - - fn is_valid(&self) -> bool { - !matches!(self, Self::UNRECOGNIZED | Self::MISSING) - } -} - -/// 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 -%} - Stub1, - Stub2, - Stub3, - {%- else -%} - {%- for context_name in model.kinds.lexical_contexts %} - {{ context_name }}, - {%- endfor %} - {%- endif -%} -} - -/// Marker trait for type-level [`LexicalContext`] variants. -pub(crate) trait IsLexicalContext { - /// Returns a run-time [`LexicalContext`] value. - fn value() -> LexicalContext; -} - -#[allow(non_snake_case)] -pub(crate) mod LexicalContextType { - {%- if not rendering_in_stubs -%} - {%- for context_name in model.kinds.lexical_contexts %} - pub struct {{ context_name }}; - - impl super::IsLexicalContext for {{ context_name }} { - fn value() -> super::LexicalContext { - super::LexicalContext::{{ context_name }} - } - } - {%- endfor %} - {%- endif -%} -} diff --git a/crates/codegen/runtime/cargo/src/runtime/mod.rs b/crates/codegen/runtime/cargo/src/runtime/mod.rs deleted file mode 100644 index 77d1b9e967..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub mod cst; -pub mod diagnostic; -pub mod parser; - -#[cfg(feature = "__experimental_bindings_api")] -pub mod bindings; - -#[cfg(feature = "__private_cli_execution")] -pub mod cli; - -#[cfg(feature = "__private_napi_interfaces")] -pub mod napi_interface; - -#[cfg(feature = "__private_wit_bindings")] -pub mod wit; diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 deleted file mode 100644 index 52d4174e57..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/ast_selectors.rs.jinja2 +++ /dev/null @@ -1,234 +0,0 @@ -#![allow(clippy::too_many_lines)] // large match statements for all non-terminals -#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling - -use std::rc::Rc; - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::{EdgeLabel, NonterminalKind, RustEdge, RustNode, RustNonterminalNode}; - -// -// Sequences: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind, -)] -pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - {%- if rendering_in_stubs -%} - unreachable!("Invoking AST selectors in stubs: {node:#?}") - {%- else -%} - let mut selector = Selector::new(node); - - let result = match node.kind() { - {%- for sequence in model.ast.sequences -%} - NonterminalKind::{{ sequence.parent_type }} => { - selector.{{ sequence.parent_type | snake_case }}_sequence()? - } - {%- endfor -%} - _ => { - return Error::UnexpectedParent(node.kind()).into(); - } - }; - - selector.finalize()?; - Ok(result) - {%- endif -%} -} - -{%- if not rendering_in_stubs -%} - {% for sequence in model.ast.sequences %} - impl Selector { - fn {{ sequence.parent_type | snake_case }}_sequence(&mut self) -> Result>>> { - Ok(vec![ - {%- for field in sequence.fields -%} - {%- if field.is_optional -%} - self.try_select(EdgeLabel::{{ field.label | pascal_case }}), - {%- else -%} - Some(self.select(EdgeLabel::{{ field.label | pascal_case }})?), - {%- endif -%} - {%- endfor -%} - ]) - } - } - {% endfor %} -{%- endif -%} - -// -// Choices: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "cst.Node", - catch_unwind, -)] -pub fn select_choice( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result> { - {%- if rendering_in_stubs -%} - unreachable!("Invoking AST selectors in stubs: {node:#?}") - {%- else -%} - let mut selector = Selector::new(node); - - let variant = selector.select(EdgeLabel::Variant)?; - - selector.finalize()?; - Ok(variant) - {%- endif -%} -} - -// -// Repeated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind, -)] -pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>> { - {%- if rendering_in_stubs -%} - unreachable!("Invoking AST selectors in stubs: {node:#?}") - {%- else -%} - let mut selector = Selector::new(node); - - let mut items = vec![]; - - while let Some(item) = selector.try_select(EdgeLabel::Item) { - items.push(item); - } - - selector.finalize()?; - Ok(items) - {%- endif -%} -} - -// -// Separated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "[Array, Array]", - catch_unwind, -)] -pub fn select_separated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - {%- if rendering_in_stubs -%} - unreachable!("Invoking AST selectors in stubs: {node:#?}") - {%- else -%} - let mut selector = Selector::new(node); - - let mut items = vec![]; - let mut separators = vec![]; - - if let Some(first) = selector.try_select(EdgeLabel::Item) { - items.push(first); - - while let Some(separator) = selector.try_select(EdgeLabel::Separator) { - separators.push(separator); - - items.push(selector.select(EdgeLabel::Item)?); - } - } - - selector.finalize()?; - Ok(vec![items, separators]) - {%- endif -%} -} - -// -// Common: -// - -struct Selector { - node: Rc, - index: usize, -} - -impl Selector { - fn new(node: &NonterminalNode) -> Self { - Self { - node: Rc::clone(&node.0), - index: 0, - } - } - - fn select(&mut self, target_label: EdgeLabel) -> Result> { - match self.try_select(target_label) { - Some(node) => Ok(node), - None => Error::MissingChild(target_label).into(), - } - } - - fn try_select(&mut self, target_label: EdgeLabel) -> Option> { - let (label, node) = self.current()?; - - if label == target_label { - self.index += 1; - Some(node.clone().into_js_either_node()) - } else { - None - } - } - - fn current(&mut self) -> Option<(EdgeLabel, RustNode)> { - loop { - let RustEdge { label, node } = self.node.children.get(self.index)?; - - match label { - // Skip unlabeled nodes: - | None - // Skip trivia: - | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { - self.index += 1; - continue; - } - // Otherwise, return the edge: - Some(other_label) => { - return Some((*other_label, node.clone())); - } - } - } - } - - fn finalize(mut self) -> Result<()> { - match self.current() { - Some((label, _)) => { - Error::UnrecognizedChild(label).into() - } - _ => Ok(()), - } - } -} - -type Result = std::result::Result; - -#[derive(Debug, thiserror::Error)] -enum Error { - // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with NonterminalKind '{0}'.")] - UnexpectedParent(NonterminalKind), - - #[error("Unrecognized child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - UnrecognizedChild(EdgeLabel), - - #[error("Missing child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - MissingChild(EdgeLabel), -} - -impl From for Result { - fn from(error: Error) -> Self { - Err(napi::Error::from_reason(error.to_string())) - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs deleted file mode 100644 index 09a4e7beff..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/cst.rs +++ /dev/null @@ -1,480 +0,0 @@ -// NAPI-exposed functions have to accept owned values -#![allow(clippy::needless_pass_by_value)] -// The functions are meant to be definitions for export, so they're not really used -#![allow(clippy::return_self_not_must_use)] - -use std::collections::HashMap; -use std::rc::Rc; - -use napi::bindgen_prelude::ClassInstance; -use napi::{Either, Env}; -use napi_derive::napi; - -use crate::napi_interface::{ - EdgeLabel, NonterminalKind, RustCursor, RustNode, RustNonterminalNode, RustQuery, - RustQueryMatch, RustQueryMatchIterator, RustTerminalNode, RustTextIndex, RustTextRange, - TerminalKind, -}; - -#[napi(namespace = "cst", string_enum)] -pub enum NodeType { - Nonterminal, - Terminal, -} - -pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; -} - -impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `NonterminalNode | TerminalNode` JS object. - fn into_js_either_node(self) -> Either { - match self { - RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), - RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), - } - } -} - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct NonterminalNode(pub(crate) Rc); - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct TerminalNode(pub(crate) Rc); - -#[napi(namespace = "cst")] -impl NonterminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Nonterminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Nonterminal - } - - #[napi(getter, ts_return_type = "cst.NonterminalKind", catch_unwind)] - pub fn kind(&self) -> NonterminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - self.0.text_len.into() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { - self.0 - .children - .iter() - .map(|child| child.node.clone().into_js_either_node()) - .collect() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Nonterminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(catch_unwind)] - pub fn unparse(&self) -> String { - Rc::clone(&self.0).unparse() - } - - // Expose the children as a hidden (non-enumerable, don't generate type definition) - // property that's eagerly evaluated (getter) for an inspected parent object in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__children", // Needed; otherwise, the property name would shadow `children`. - skip_typescript, - catch_unwind - )] - pub fn __children(&self) -> Vec> { - Self::children(self) - } - - // Similarly, expose the eagerly evaluated unparsed text in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__text", - skip_typescript, - catch_unwind - )] - pub fn __text(&self) -> String { - self.unparse() - } -} - -#[napi(namespace = "cst")] -impl TerminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Terminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Terminal - } - - #[napi(getter, ts_return_type = "cst.TerminalKind", catch_unwind)] - pub fn kind(&self) -> TerminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - let text_len: RustTextIndex = (&self.0.text).into(); - text_len.into() - } - - #[napi(getter, catch_unwind)] - pub fn text(&self) -> String { - self.0.text.clone() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Terminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } -} - -#[napi(namespace = "cst")] -pub struct Cursor(pub(super) RustCursor); - -impl From for Cursor { - fn from(value: RustCursor) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Cursor { - pub(crate) fn new(cursor: RustCursor) -> Self { - Self(cursor) - } - - #[napi(catch_unwind)] - pub fn reset(&mut self) { - self.0.reset(); - } - - #[napi(catch_unwind)] - pub fn complete(&mut self) { - self.0.complete(); - } - - #[must_use] - #[napi(catch_unwind)] - #[allow(clippy::should_implement_trait)] // These are meant to be explicitly exposed to NAPI - pub fn clone(&self) -> Self { - Self(self.0.clone()) - } - - #[must_use] - #[napi(catch_unwind)] - pub fn spawn(&self) -> Self { - Self::new(self.0.spawn()) - } - - #[napi(getter, catch_unwind)] - pub fn is_completed(&self) -> bool { - self.0.is_completed() - } - - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { - self.0.node().into_js_either_node() - } - - #[napi(getter, ts_return_type = "cst.EdgeLabel", catch_unwind)] - pub fn label(&self) -> Option { - self.0.label() - } - - #[napi(getter, ts_return_type = "cst.TextIndex", catch_unwind)] - pub fn text_offset(&self) -> TextIndex { - self.0.text_offset().into() - } - - #[napi(getter, ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 - #[napi(getter, catch_unwind)] - pub fn depth(&self) -> u32 { - self.0.depth() as u32 - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(NonterminalNode).collect() - } - - #[napi(catch_unwind)] - pub fn go_to_next(&mut self) -> bool { - self.0.go_to_next() - } - - #[napi(catch_unwind)] - pub fn go_to_next_non_descendent(&mut self) -> bool { - self.0.go_to_next_non_descendent() - } - - #[napi(catch_unwind)] - pub fn go_to_previous(&mut self) -> bool { - self.0.go_to_previous() - } - - #[napi(catch_unwind)] - pub fn go_to_parent(&mut self) -> bool { - self.0.go_to_parent() - } - - #[napi(catch_unwind)] - pub fn go_to_first_child(&mut self) -> bool { - self.0.go_to_first_child() - } - - #[napi(catch_unwind)] - pub fn go_to_last_child(&mut self) -> bool { - self.0.go_to_last_child() - } - - #[napi(catch_unwind)] - pub fn go_to_nth_child(&mut self, child_number: u32) -> bool { - self.0.go_to_nth_child(child_number as usize) - } - - #[napi(catch_unwind)] - pub fn go_to_next_sibling(&mut self) -> bool { - self.0.go_to_next_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_previous_sibling(&mut self) -> bool { - self.0.go_to_previous_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal(&mut self) -> bool { - self.0.go_to_next_terminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.TerminalKind")] kind: TerminalKind, - ) -> bool { - self.0.go_to_next_terminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_terminal_with_kinds(&kinds) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal(&mut self) -> bool { - self.0.go_to_next_nonterminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - ) -> bool { - self.0.go_to_next_nonterminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_nonterminal_with_kinds(&kinds) - } -} - -#[napi(namespace = "cst")] -pub struct Query(RustQuery); - -impl From for Query { - fn from(value: RustQuery) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Query { - #[napi(factory, catch_unwind)] - pub fn parse(text: String) -> napi::Result { - RustQuery::parse(text.as_str()).map_or_else( - |err| Err(napi::Error::from_reason(err.message)), - |query| Ok(query.into()), - ) - } -} - -#[napi(namespace = "cst")] -pub struct QueryMatchIterator(RustQueryMatchIterator); - -#[napi(object, namespace = "cst")] -pub struct QueryMatch { - pub query_number: u32, - #[napi(ts_type = "{ [key: string]: cst.Cursor[] }")] - pub captures: HashMap>>, -} - -impl QueryMatch { - fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { - #[allow(clippy::cast_possible_truncation)] - let query_number = r#match.query_number as u32; - // transfer all of the captures eagerly on the assumption - // that they've all been explicitly requested. - let captures = r#match - .captures - .into_iter() - .map(|(key, values)| { - let instances = values - .into_iter() - .map(|cursor| Cursor(cursor).into_instance(env)) - .collect::>()?; - - Ok((key, instances)) - }) - .collect::>()?; - - Ok(Self { - query_number, - captures, - }) - } -} - -impl From for QueryMatchIterator { - fn from(value: RustQueryMatchIterator) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl QueryMatchIterator { - #[napi(catch_unwind)] - pub fn next(&mut self, env: Env) -> napi::Result> { - match self.0.next() { - Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), - None => Ok(None), - } - } -} - -#[napi(namespace = "cst")] -impl Cursor { - #[napi(ts_return_type = "cst.QueryMatchIterator", catch_unwind)] - pub fn query( - &self, - #[napi(ts_arg_type = "Array")] queries: Vec<&Query>, - ) -> QueryMatchIterator { - self.0 - .clone() - .query(queries.into_iter().map(|x| x.0.clone()).collect()) - .into() - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextIndex { - pub utf8: u32, - pub utf16: u32, - pub line: u32, - pub column: u32, -} - -impl From for TextIndex { - fn from(value: RustTextIndex) -> Self { - // We only support 32-byte indices on TS side. - #[allow(clippy::cast_possible_truncation)] - Self { - utf8: value.utf8 as u32, - utf16: value.utf16 as u32, - line: value.line as u32, - column: value.column as u32, - } - } -} - -impl From for RustTextIndex { - fn from(value: TextIndex) -> Self { - Self { - utf8: value.utf8 as usize, - utf16: value.utf16 as usize, - line: value.line as usize, - column: value.column as usize, - } - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextRange { - pub start: TextIndex, - pub end: TextIndex, -} - -impl From for TextRange { - fn from(value: RustTextRange) -> Self { - Self { - start: value.start.into(), - end: value.end.into(), - } - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/diagnostic.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/diagnostic.rs deleted file mode 100644 index f9920063ef..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/diagnostic.rs +++ /dev/null @@ -1,78 +0,0 @@ -use napi_derive::napi; - -use crate::napi_interface::cst::TextRange; - -/// Severity of the compiler diagnostic. -/// -/// Explicitly compatible with the LSP protocol. -#[napi(namespace = "diagnostic")] -pub enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, -} - -impl From for Severity { - fn from(value: crate::diagnostic::Severity) -> Severity { - match value { - crate::diagnostic::Severity::Error => Self::Error, - crate::diagnostic::Severity::Warning => Self::Warning, - crate::diagnostic::Severity::Information => Self::Information, - crate::diagnostic::Severity::Hint => Self::Hint, - } - } -} - -/// A compiler diagnostic that can be rendered to a user. -#[napi(namespace = "diagnostic")] -pub struct Diagnostic(pub(crate) Box); - -#[napi(namespace = "diagnostic")] -impl Diagnostic { - /// The severity of this diagnostic. - #[napi] - pub fn severity(&self) -> Severity { - self.0.severity().into() - } - - /// The character range of the source that this diagnostic applies to. - #[napi(ts_return_type = "cst.TextRange")] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - /// The primary message associated with this diagnostic. - #[napi] - pub fn message(&self) -> String { - self.0.message() - } -} - -/// Exposes the [`Diagnostic`](crate::diagnostic::Diagnostic) methods implemented for a given type -/// as regular N-API functions, satisfying the custom `DiagnosticInterface` interface on the N-API side. -// NOTE(#987): This is required because we can't directly expose the trait using `#[napi]` or expose -// an interface that has only methods defined. -// To not require explicit conversions, we define the interface ourselves and expose the relevant methods to satisfy it. -#[macro_export] -macro_rules! expose_diagnostic_trait_interface { - ($namespace:literal, $diagnostic:ty) => { - #[napi(namespace = $namespace)] - impl $diagnostic { - #[napi(ts_return_type = "diagnostic.Severity", catch_unwind)] - pub fn severity(&self) -> $crate::napi_interface::diagnostic::Severity { - $crate::diagnostic::Diagnostic::severity(&self.0).into() - } - - #[napi(ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> $crate::napi_interface::cst::TextRange { - $crate::diagnostic::Diagnostic::text_range(&self.0).into() - } - - #[napi] - pub fn message(&self) -> String { - $crate::diagnostic::Diagnostic::message(&self.0) - } - } - }; -} diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs deleted file mode 100644 index ba24f0ca0e..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/generated/ast_selectors.rs +++ /dev/null @@ -1,153 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#![allow(clippy::too_many_lines)] // large match statements for all non-terminals -#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling - -use std::rc::Rc; - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::{EdgeLabel, NonterminalKind, RustEdge, RustNode, RustNonterminalNode}; - -// -// Sequences: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - unreachable!("Invoking AST selectors in stubs: {node:#?}") -} // - // Choices: - // - -#[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] -pub fn select_choice( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result> { - unreachable!("Invoking AST selectors in stubs: {node:#?}") -} - -// -// Repeated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>> { - unreachable!("Invoking AST selectors in stubs: {node:#?}") -} - -// -// Separated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "[Array, Array]", - catch_unwind -)] -pub fn select_separated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - unreachable!("Invoking AST selectors in stubs: {node:#?}") -} - -// -// Common: -// - -struct Selector { - node: Rc, - index: usize, -} - -impl Selector { - fn new(node: &NonterminalNode) -> Self { - Self { - node: Rc::clone(&node.0), - index: 0, - } - } - - fn select(&mut self, target_label: EdgeLabel) -> Result> { - match self.try_select(target_label) { - Some(node) => Ok(node), - None => Error::MissingChild(target_label).into(), - } - } - - fn try_select( - &mut self, - target_label: EdgeLabel, - ) -> Option> { - let (label, node) = self.current()?; - - if label == target_label { - self.index += 1; - Some(node.clone().into_js_either_node()) - } else { - None - } - } - - fn current(&mut self) -> Option<(EdgeLabel, RustNode)> { - loop { - let RustEdge { label, node } = self.node.children.get(self.index)?; - - match label { - // Skip unlabeled nodes: - | None - // Skip trivia: - | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { - self.index += 1; - continue; - } - // Otherwise, return the edge: - Some(other_label) => { - return Some((*other_label, node.clone())); - } - } - } - } - - fn finalize(mut self) -> Result<()> { - match self.current() { - Some((label, _)) => Error::UnrecognizedChild(label).into(), - _ => Ok(()), - } - } -} - -type Result = std::result::Result; - -#[derive(Debug, thiserror::Error)] -enum Error { - // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with NonterminalKind '{0}'.")] - UnexpectedParent(NonterminalKind), - - #[error("Unrecognized child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - UnrecognizedChild(EdgeLabel), - - #[error("Missing child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - MissingChild(EdgeLabel), -} - -impl From for Result { - fn from(error: Error) -> Self { - Err(napi::Error::from_reason(error.to_string())) - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs deleted file mode 100644 index 2bb075eb0d..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -pub mod cst; -pub mod diagnostic; -pub mod parser; - -#[path = "generated/ast_selectors.rs"] -pub mod ast_selectors; - -type RustCursor = crate::cst::Cursor; -type RustEdge = crate::cst::Edge; -type RustNode = crate::cst::Node; -type RustParseError = crate::parser::ParseError; -type RustParseOutput = crate::parser::ParseOutput; -type RustQuery = crate::cst::Query; -type RustQueryMatch = crate::cst::QueryMatch; -type RustQueryMatchIterator = crate::cst::QueryMatchIterator; -type RustNonterminalNode = crate::cst::NonterminalNode; -type RustTextIndex = crate::cst::TextIndex; -type RustTextRange = crate::cst::TextRange; -type RustTerminalNode = crate::cst::TerminalNode; - -type NonterminalKind = crate::cst::NonterminalKind; -type TerminalKind = crate::cst::TerminalKind; -type EdgeLabel = crate::cst::EdgeLabel; diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/mod.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/mod.rs deleted file mode 100644 index 1b96dbc043..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod parse_error; -mod parse_output; - -pub use parse_error::ParseError; -pub use parse_output::ParseOutput; diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_error.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_error.rs deleted file mode 100644 index f0a74e5b63..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_error.rs +++ /dev/null @@ -1,19 +0,0 @@ -// NAPI-exposed functions have to accept owned values. -#![allow(clippy::needless_pass_by_value)] - -use napi_derive::napi; - -use crate::expose_diagnostic_trait_interface; -use crate::napi_interface::RustParseError; - -#[napi(namespace = "parser")] -#[derive(PartialEq, Clone)] -pub struct ParseError(RustParseError); - -impl From for ParseError { - fn from(value: RustParseError) -> Self { - Self(value) - } -} - -expose_diagnostic_trait_interface!("parser", ParseError); diff --git a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_output.rs b/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_output.rs deleted file mode 100644 index 56ce7a6c96..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/napi_interface/parser/parse_output.rs +++ /dev/null @@ -1,39 +0,0 @@ -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{Cursor, NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::parser::ParseError; -use crate::napi_interface::RustParseOutput; - -#[napi(namespace = "parser")] -pub struct ParseOutput(RustParseOutput); - -impl From for ParseOutput { - fn from(value: RustParseOutput) -> Self { - Self(value) - } -} - -#[napi(namespace = "parser")] -impl ParseOutput { - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { - self.0.tree().into_js_either_node() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn errors(&self) -> Vec { - self.0.errors().iter().map(|x| x.clone().into()).collect() - } - - #[napi(getter, catch_unwind)] - pub fn is_valid(&self) -> bool { - self.0.is_valid() - } - - /// Creates a cursor that starts at the root of the parse tree. - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_tree_cursor(&self) -> Cursor { - self.0.create_tree_cursor().into() - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/_types.rs.jinja2 b/crates/codegen/runtime/cargo/src/runtime/wit/interface/_types.rs.jinja2 deleted file mode 100644 index accc374951..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/_types.rs.jinja2 +++ /dev/null @@ -1,10 +0,0 @@ -// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. -// You can use 'cargo expand' to see its output, or run the CLI version directly of 'wit-bindgen' via: -// -// wit-bindgen rust "./generated" --pub-export-macro --out-dir "./target/wit/" - -{% if rendering_in_stubs -%} - wit_bindgen::generate!(in "src/runtime/wit/interface/generated"); -{%- else -%} - wit_bindgen::generate!(in "src/generated/wit/interface/generated"); -{%- endif -%} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/diagnostic.wit.jinja2 b/crates/codegen/runtime/cargo/src/runtime/wit/interface/diagnostic.wit.jinja2 deleted file mode 100644 index 3967c73e5a..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/diagnostic.wit.jinja2 +++ /dev/null @@ -1,8 +0,0 @@ -interface diagnostic { - enum severity { - error, - warning, - information, - hint, - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_types.rs b/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_types.rs deleted file mode 100644 index 8bf8844243..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_types.rs +++ /dev/null @@ -1,8 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. -// You can use 'cargo expand' to see its output, or run the CLI version directly of 'wit-bindgen' via: -// -// wit-bindgen rust "./generated" --pub-export-macro --out-dir "./target/wit/" - -wit_bindgen::generate!(in "src/runtime/wit/interface/generated"); diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/diagnostic.wit b/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/diagnostic.wit deleted file mode 100644 index 000fcaf719..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/diagnostic.wit +++ /dev/null @@ -1,10 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -interface diagnostic { - enum severity { - error, - warning, - information, - hint, - } -} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs b/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs deleted file mode 100644 index 47e111717e..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[path = "./interface/generated/_types.rs"] -mod interface; -mod utils; -mod wrappers; - -struct World; - -crate::wit::interface::export!(World with_types_in crate::wit::interface); diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/diagnostic.rs b/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/diagnostic.rs deleted file mode 100644 index 2db215b1b2..0000000000 --- a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/diagnostic.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::wit::utils::enum_to_enum; - -mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; -} - -mod rust { - pub use crate::diagnostic::Severity; -} - -//================================================ -// -// enum severity -// -//================================================ - -enum_to_enum!(Severity); diff --git a/crates/codegen/runtime/cargo/wasm/Cargo.toml b/crates/codegen/runtime/cargo/wasm/Cargo.toml new file mode 100644 index 0000000000..bd8bcc7a90 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "codegen_runtime_cargo_wasm" +version.workspace = true +rust-version.workspace = true +edition.workspace = true +publish = false + +# At the time of writing, building 'cdylib' plugins with Cargo has limited support +# (see for the general tracking issue). +# To workaround some of the issues, we create a separate 'cdylib' crate that defines the WASM wrappers. +[lib] +crate-type = ["cdylib"] + +[build-dependencies] +anyhow = { workspace = true } +codegen_runtime_generator = { workspace = true } +infra_utils = { workspace = true } + +[dependencies] +codegen_runtime_cargo_crate = { workspace = true } +paste = { workspace = true } +semver = { workspace = true } +serde_json = { workspace = true } +wit-bindgen = { workspace = true } + +[lints] +workspace = true diff --git a/crates/codegen/runtime/cargo/wasm/build.rs b/crates/codegen/runtime/cargo/wasm/build.rs new file mode 100644 index 0000000000..64c35c2d98 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/build.rs @@ -0,0 +1,9 @@ +use anyhow::Result; +use codegen_runtime_generator::RuntimeGenerator; +use infra_utils::cargo::CargoWorkspace; + +fn main() -> Result<()> { + let source_dir = CargoWorkspace::locate_source_crate("codegen_runtime_cargo_wasm")?; + + RuntimeGenerator::generate_stubs(&source_dir) +} diff --git a/crates/codegen/runtime/cargo/wasm/src/lib.rs b/crates/codegen/runtime/cargo/wasm/src/lib.rs new file mode 100644 index 0000000000..2429171685 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/lib.rs @@ -0,0 +1,7 @@ +// Disable dead-code checking in this stubs crate, as they are not necissarily used in tests. +// The final code (generated in output crates) is checked for dead-code anyways. +#![allow(dead_code, unused_imports)] + +mod runtime; + +use {codegen_runtime_cargo_crate as rust_crate, runtime as wasm_crate}; diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/bindings.rs.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/bindings.rs.jinja2 new file mode 100644 index 0000000000..95b4978f83 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/bindings.rs.jinja2 @@ -0,0 +1,8 @@ +// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. +// You can use 'cargo expand' to see its output, or run the 'wit-bindgen rust' command. + +{% if rendering_in_stubs -%} + wit_bindgen::generate!(in "src/runtime/interface/generated"); +{%- else -%} + wit_bindgen::generate!(in "src/generated/interface/generated"); +{%- endif -%} diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/config.json.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/config.json.jinja2 new file mode 100644 index 0000000000..f642396029 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/config.json.jinja2 @@ -0,0 +1,139 @@ +{ + "mappings": { + "nomic-foundation:slang:cst:terminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:nonterminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:edge-label": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:node": { + "Variant": { + "as_direct_union_of_resource_classes": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:terminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.node()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.label()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-offset()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.depth()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.ancestors()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:query-match.captures": { + "ListOfTuple": { + "as_dictionary": true + } + }, + "nomic-foundation:slang:cst:query-match-iterator": { + "Resource": { + "as_iterator": true + } + }, + "nomic-foundation:slang:parser:parser.version()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.message()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.tree()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.errors()": { + "Function": { + "as_getter": true + } + } + } +} diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/generated/bindings.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/generated/bindings.rs new file mode 100644 index 0000000000..4450b825d5 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/generated/bindings.rs @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. +// You can use 'cargo expand' to see its output, or run the 'wit-bindgen rust' command. + +wit_bindgen::generate!(in "src/runtime/interface/generated"); diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/generated/config.json b/crates/codegen/runtime/cargo/wasm/src/runtime/generated/config.json new file mode 100644 index 0000000000..f642396029 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/generated/config.json @@ -0,0 +1,139 @@ +{ + "mappings": { + "nomic-foundation:slang:cst:terminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:nonterminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:edge-label": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:node": { + "Variant": { + "as_direct_union_of_resource_classes": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:terminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.node()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.label()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-offset()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.depth()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.ancestors()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:query-match.captures": { + "ListOfTuple": { + "as_dictionary": true + } + }, + "nomic-foundation:slang:cst:query-match-iterator": { + "Resource": { + "as_iterator": true + } + }, + "nomic-foundation:slang:parser:parser.version()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.message()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.tree()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.errors()": { + "Function": { + "as_getter": true + } + } + } +} diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/ast.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/ast.wit.jinja2 new file mode 100644 index 0000000000..2aceef75c9 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/ast.wit.jinja2 @@ -0,0 +1,10 @@ +interface ast { + use cst.{node, nonterminal-node}; + + resource selectors { + sequence: static func(node: nonterminal-node) -> result>, string>; + choice: static func(node: nonterminal-node) -> result; + repeated: static func(node: nonterminal-node) -> result, string>; + separated: static func(node: nonterminal-node) -> result>, string>; + } +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/cst.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/cst.wit.jinja2 similarity index 84% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/cst.wit.jinja2 rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/cst.wit.jinja2 index 0443501116..ebed2be2b5 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/cst.wit.jinja2 +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/cst.wit.jinja2 @@ -11,11 +11,10 @@ interface cst { {%- endif %} } - enum edge-label { + enum terminal-kind { // Built-in: - {%- for label in model.kinds.built_in_labels %} - {{ label | wit_case }}, - {%- endfor %} + unrecognized, + missing, // Generated: {%- if rendering_in_stubs %} @@ -23,15 +22,22 @@ interface cst { stub2, stub3, {%- else %} - {%- for variant in model.kinds.labels %} + {%- for variant in model.kinds.terminal_kinds %} {{ variant | wit_case }}, {%- endfor %} {%- endif %} } - enum terminal-kind { + resource terminal-kind-extensions { + is-trivia: static func(kind: terminal-kind) -> bool; + is-valid: static func(kind: terminal-kind) -> bool; + } + + enum edge-label { // Built-in: - skipped, + {%- for label in model.kinds.built_in_labels %} + {{ label | wit_case }}, + {%- endfor %} // Generated: {%- if rendering_in_stubs %} @@ -39,7 +45,7 @@ interface cst { stub2, stub3, {%- else %} - {%- for variant in model.kinds.terminal_kinds %} + {%- for variant in model.kinds.labels %} {{ variant | wit_case }}, {%- endfor %} {%- endif %} @@ -51,17 +57,30 @@ interface cst { } resource nonterminal-node { + id: func() -> u32; kind: func() -> nonterminal-kind; - text-len: func() -> text-index; - children: func() -> list; - create-cursor: func(text-offset: text-index) -> cursor; + text-length: func() -> text-index; + + children: func() -> list; unparse: func() -> string; + to-json: func() -> string; + + create-cursor: func(text-offset: text-index) -> cursor; } resource terminal-node { + id: func() -> u32; kind: func() -> terminal-kind; - text-len: func() -> text-index; - text: func() -> string; + text-length: func() -> text-index; + + children: func() -> list; + unparse: func() -> string; + to-json: func() -> string; + } + + record edge { + label: option, + node: node, } resource cursor { @@ -112,7 +131,7 @@ interface cst { record query-error { message: string, - row: u32, + line: u32, column: u32, } diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/ast.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/ast.wit new file mode 100644 index 0000000000..31c6a91f88 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/ast.wit @@ -0,0 +1,12 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface ast { + use cst.{node, nonterminal-node}; + + resource selectors { + sequence: static func(node: nonterminal-node) -> result>, string>; + choice: static func(node: nonterminal-node) -> result; + repeated: static func(node: nonterminal-node) -> result, string>; + separated: static func(node: nonterminal-node) -> result>, string>; + } +} diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/cst.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/cst.wit similarity index 82% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/cst.wit rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/cst.wit index ab2fd3b8bc..0754a74cf9 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/cst.wit +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/cst.wit @@ -7,6 +7,22 @@ interface cst { stub3, } + enum terminal-kind { + // Built-in: + unrecognized, + missing, + + // Generated: + stub1, + stub2, + stub3, + } + + resource terminal-kind-extensions { + is-trivia: static func(kind: terminal-kind) -> bool; + is-valid: static func(kind: terminal-kind) -> bool; + } + enum edge-label { // Built-in: %item, @@ -24,33 +40,36 @@ interface cst { stub3, } - enum terminal-kind { - // Built-in: - skipped, - - // Generated: - stub1, - stub2, - stub3, - } - variant node { nonterminal(nonterminal-node), terminal(terminal-node) } resource nonterminal-node { + id: func() -> u32; kind: func() -> nonterminal-kind; - text-len: func() -> text-index; - children: func() -> list; - create-cursor: func(text-offset: text-index) -> cursor; + text-length: func() -> text-index; + + children: func() -> list; unparse: func() -> string; + to-json: func() -> string; + + create-cursor: func(text-offset: text-index) -> cursor; } resource terminal-node { + id: func() -> u32; kind: func() -> terminal-kind; - text-len: func() -> text-index; - text: func() -> string; + text-length: func() -> text-index; + + children: func() -> list; + unparse: func() -> string; + to-json: func() -> string; + } + + record edge { + label: option, + node: node, } resource cursor { @@ -101,7 +120,7 @@ interface cst { record query-error { message: string, - row: u32, + line: u32, column: u32, } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/parser.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/parser.wit similarity index 83% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/parser.wit rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/parser.wit index 8381cb836d..f5ae55423e 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/parser.wit +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/parser.wit @@ -2,17 +2,17 @@ interface parser { use cst.{cursor, node, nonterminal-kind, text-range}; - use diagnostic.{severity}; resource parser { + root-kind: static func() -> nonterminal-kind; supported-versions: static func() -> list; - new: static func(version: string) -> result; + create: static func(version: string) -> result; + version: func() -> string; parse: func(kind: nonterminal-kind, input: string) -> parse-output; } resource parse-error { - severity: func() -> severity; text-range: func() -> text-range; message: func() -> string; } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_world.wit b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit similarity index 88% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_world.wit rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit index 7f826767f4..c5e1378860 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_world.wit +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/world.wit @@ -3,7 +3,7 @@ package nomic-foundation:slang; world slang { + export ast; export cst; - export diagnostic; export parser; } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/parser.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/parser.wit.jinja2 similarity index 80% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/parser.wit.jinja2 rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/parser.wit.jinja2 index 475c425c47..d5b863f353 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/parser.wit.jinja2 +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/parser.wit.jinja2 @@ -1,16 +1,16 @@ interface parser { use cst.{cursor, node, nonterminal-kind, text-range}; - use diagnostic.{severity}; resource parser { + root-kind: static func() -> nonterminal-kind; supported-versions: static func() -> list; - new: static func(version: string) -> result; + create: static func(version: string) -> result; + version: func() -> string; parse: func(kind: nonterminal-kind, input: string) -> parse-output; } resource parse-error { - severity: func() -> severity; text-range: func() -> text-range; message: func() -> string; } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/_world.wit.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 similarity index 78% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/_world.wit.jinja2 rename to crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 index 6e6259b042..395b2ec702 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/_world.wit.jinja2 +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/interface/world.wit.jinja2 @@ -1,7 +1,7 @@ package nomic-foundation:slang; world slang { + export ast; export cst; - export diagnostic; export parser; } diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/mod.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/mod.rs new file mode 100644 index 0000000000..ed55e0e62e --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/mod.rs @@ -0,0 +1,8 @@ +#[path = "./generated/bindings.rs"] +mod bindings; +mod utils; +mod wrappers; + +struct World; + +crate::wasm_crate::bindings::export!(World with_types_in crate::wasm_crate::bindings); diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/utils.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/utils.rs similarity index 88% rename from crates/codegen/runtime/cargo/src/runtime/wit/utils.rs rename to crates/codegen/runtime/cargo/wasm/src/runtime/utils.rs index 2bc639dd73..1fe67a96cf 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/utils.rs +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/utils.rs @@ -12,14 +12,14 @@ macro_rules! define_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (rust::$name); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0 @@ -61,14 +61,14 @@ macro_rules! define_rc_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::rc::Rc); - impl $crate::wit::utils::IntoFFI for std::rc::Rc { + impl $crate::wasm_crate::utils::IntoFFI for std::rc::Rc { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI> for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI> for ffi::$name { #[inline] fn _from_ffi(self) -> std::rc::Rc { self.into_inner::<[<$name Wrapper>]>().0 @@ -110,14 +110,14 @@ macro_rules! define_refcell_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::cell::RefCell); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0.into_inner() @@ -167,14 +167,14 @@ macro_rules! define_refcell_wrapper { macro_rules! enum_to_enum { ($name:ident) => { - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { unsafe { core::mem::transmute(self) } } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { unsafe { core::mem::transmute(self) } diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs new file mode 100644 index 0000000000..b2e9d15bbc --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs @@ -0,0 +1,111 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#![allow(clippy::too_many_lines)] // large match statements for all non-terminals +#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling + +use std::rc::Rc; + +use crate::rust_crate::cst::{Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode}; + +// +// Sequences: +// + +pub fn select_sequence(node: &Rc) -> Result>> { + Err(format!("Invoking AST selectors in stubs: {node:#?}")) +} // + // Choices: + // + +pub fn select_choice(node: &Rc) -> Result { + Err(format!("Invoking AST selectors in stubs: {node:#?}")) +} + +// +// Repeated: +// + +pub fn select_repeated(node: &Rc) -> Result> { + Err(format!("Invoking AST selectors in stubs: {node:#?}")) +} + +// +// Separated: +// + +pub fn select_separated(node: &Rc) -> Result>> { + Err(format!("Invoking AST selectors in stubs: {node:#?}")) +} + +// +// Common: +// + +type Result = std::result::Result; + +struct Helper { + node: Rc, + index: usize, +} + +impl Helper { + fn new(node: &Rc) -> Self { + Self { + node: Rc::clone(node), + index: 0, + } + } + + fn select(&mut self, target_label: EdgeLabel) -> Result { + match self.try_select(target_label) { + Some(node) => { + Ok(node) + }, + None => { + Err(format!("Missing child with label '{target_label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + } + } + + fn try_select(&mut self, target_label: EdgeLabel) -> Option { + let (label, node) = self.current()?; + + if label == target_label { + self.index += 1; + Some(node.clone()) + } else { + None + } + } + + fn current(&mut self) -> Option<(EdgeLabel, Node)> { + loop { + let Edge { label, node } = self.node.children.get(self.index)?; + + match label { + // Skip unlabeled nodes: + | None + // Skip trivia: + | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { + self.index += 1; + continue; + } + // Otherwise, return the edge: + Some(other_label) => { + return Some((*other_label, node.clone())); + } + } + } + } + + fn finalize(mut self) -> Result<()> { + match self.current() { + Some((label, _)) => { + Err(format!("Unrecognized child with label '{label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + None => { + Ok(()) + }, + } + } +} diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/mod.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/mod.rs new file mode 100644 index 0000000000..1a4b3c6eee --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/mod.rs @@ -0,0 +1,54 @@ +#[path = "generated/selectors.rs"] +mod selectors; + +use crate::wasm_crate::utils::IntoFFI; + +mod ffi { + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::ast::{ + Guest, GuestSelectors, + }; + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Node, NonterminalNode, + }; +} + +mod rust {} + +impl ffi::Guest for crate::wasm_crate::World { + type Selectors = SelectorsWrapper; +} + +//================================================ +// +// resource selectors +// +//================================================ + +pub struct SelectorsWrapper; + +impl ffi::GuestSelectors for SelectorsWrapper { + fn sequence(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_sequence(node._borrow_ffi())? + .into_iter() + .map(|opt| opt.map(|node| node._into_ffi())) + .collect()) + } + + fn choice(node: ffi::NonterminalNode) -> Result { + Ok(selectors::select_choice(node._borrow_ffi())?._into_ffi()) + } + + fn repeated(node: ffi::NonterminalNode) -> Result, String> { + Ok(selectors::select_repeated(node._borrow_ffi())? + .into_iter() + .map(|node| node._into_ffi()) + .collect()) + } + + fn separated(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_separated(node._borrow_ffi())? + .into_iter() + .map(|vec| vec.into_iter().map(|node| node._into_ffi()).collect()) + .collect()) + } +} diff --git a/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/selectors.rs.jinja2 b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/selectors.rs.jinja2 new file mode 100644 index 0000000000..c712656588 --- /dev/null +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/selectors.rs.jinja2 @@ -0,0 +1,191 @@ +#![allow(clippy::too_many_lines)] // large match statements for all non-terminals +#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling + +use std::rc::Rc; + +use crate::rust_crate::cst::{Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode}; + +// +// Sequences: +// + +pub fn select_sequence(node: &Rc) -> Result>> { + {%- if rendering_in_stubs -%} + Err(format!("Invoking AST selectors in stubs: {node:#?}")) + {%- else -%} + let mut helper = Helper::new(node); + + let result = match node.kind { + {%- for sequence in model.ast.sequences -%} + NonterminalKind::{{ sequence.parent_type }} => { + helper.{{ sequence.parent_type | snake_case }}_sequence()? + } + {%- endfor -%} + _ => { + // Should not theoretically happen, since we're only called from our own generated AST types. + return Err(format!("Unexpected parent node with NonterminalKind '{0}'.", node.kind)); + } + }; + + helper.finalize()?; + Ok(result) + {%- endif -%} +} + +{%- if not rendering_in_stubs -%} + {% for sequence in model.ast.sequences %} + impl Helper { + fn {{ sequence.parent_type | snake_case }}_sequence(&mut self) -> Result>> { + Ok(vec![ + {%- for field in sequence.fields -%} + {%- if field.is_optional -%} + self.try_select(EdgeLabel::{{ field.label | pascal_case }}), + {%- else -%} + Some(self.select(EdgeLabel::{{ field.label | pascal_case }})?), + {%- endif -%} + {%- endfor -%} + ]) + } + } + {% endfor %} +{%- endif -%} + +// +// Choices: +// + +pub fn select_choice(node: &Rc) -> Result { + {%- if rendering_in_stubs -%} + Err(format!("Invoking AST selectors in stubs: {node:#?}")) + {%- else -%} + let mut helper = Helper::new(node); + + let variant = helper.select(EdgeLabel::Variant)?; + + helper.finalize()?; + Ok(variant) + {%- endif -%} +} + +// +// Repeated: +// + +pub fn select_repeated(node: &Rc) -> Result> { + {%- if rendering_in_stubs -%} + Err(format!("Invoking AST selectors in stubs: {node:#?}")) + {%- else -%} + let mut helper = Helper::new(node); + + let mut items = vec![]; + + while let Some(item) = helper.try_select(EdgeLabel::Item) { + items.push(item); + } + + helper.finalize()?; + Ok(items) + {%- endif -%} +} + +// +// Separated: +// + +pub fn select_separated(node: &Rc) -> Result>> { + {%- if rendering_in_stubs -%} + Err(format!("Invoking AST selectors in stubs: {node:#?}")) + {%- else -%} + let mut helper = Helper::new(node); + + let mut items = vec![]; + let mut separators = vec![]; + + if let Some(first) = helper.try_select(EdgeLabel::Item) { + items.push(first); + + while let Some(separator) = helper.try_select(EdgeLabel::Separator) { + separators.push(separator); + + items.push(helper.select(EdgeLabel::Item)?); + } + } + + helper.finalize()?; + Ok(vec![items, separators]) + {%- endif -%} +} + +// +// Common: +// + +type Result = std::result::Result; + +struct Helper { + node: Rc, + index: usize, +} + +impl Helper { + fn new(node: &Rc) -> Self { + Self { + node: Rc::clone(node), + index: 0, + } + } + + fn select(&mut self, target_label: EdgeLabel) -> Result { + match self.try_select(target_label) { + Some(node) => { + Ok(node) + }, + None => { + Err(format!("Missing child with label '{target_label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + } + } + + fn try_select(&mut self, target_label: EdgeLabel) -> Option { + let (label, node) = self.current()?; + + if label == target_label { + self.index += 1; + Some(node.clone()) + } else { + None + } + } + + fn current(&mut self) -> Option<(EdgeLabel, Node)> { + loop { + let Edge { label, node } = self.node.children.get(self.index)?; + + match label { + // Skip unlabeled nodes: + | None + // Skip trivia: + | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { + self.index += 1; + continue; + } + // Otherwise, return the edge: + Some(other_label) => { + return Some((*other_label, node.clone())); + } + } + } + } + + fn finalize(mut self) -> Result<()> { + match self.current() { + Some((label, _)) => { + Err(format!("Unrecognized child with label '{label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + None => { + Ok(()) + }, + } + } +} + diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/cst.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/cst/mod.rs similarity index 72% rename from crates/codegen/runtime/cargo/src/runtime/wit/wrappers/cst.rs rename to crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/cst/mod.rs index b8e9393d47..7a4dfba1ed 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/cst.rs +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/cst/mod.rs @@ -1,25 +1,27 @@ -use crate::wit::utils::{ +use crate::wasm_crate::utils::{ define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum, FromFFI, IntoFFI, }; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ - Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, GuestQuery, - GuestQueryMatchIterator, GuestTerminalNode, Node, NonterminalKind, NonterminalNode, - NonterminalNodeBorrow, Query, QueryBorrow, QueryError, QueryMatch, QueryMatchIterator, - QueryMatchIteratorBorrow, TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, - TextRange, + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Cursor, CursorBorrow, Edge, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, + GuestQuery, GuestQueryMatchIterator, GuestTerminalKindExtensions, GuestTerminalNode, Node, + NonterminalKind, NonterminalNode, NonterminalNodeBorrow, Query, QueryBorrow, QueryError, + QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, TerminalKind, TerminalNode, + TerminalNodeBorrow, TextIndex, TextRange, }; } mod rust { - pub use crate::cst::{ - Cursor, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, QueryMatch, - QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, + pub use crate::rust_crate::cst::{ + Cursor, Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, + QueryMatch, QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, }; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { + type TerminalKindExtensions = TerminalKindExtensionsWrapper; + type NonterminalNode = NonterminalNodeWrapper; type TerminalNode = TerminalNodeWrapper; @@ -45,6 +47,24 @@ enum_to_enum!(NonterminalKind); enum_to_enum!(TerminalKind); +//================================================ +// +// resource terminal-kind-extensions +// +//================================================ + +pub struct TerminalKindExtensionsWrapper; + +impl ffi::GuestTerminalKindExtensions for TerminalKindExtensionsWrapper { + fn is_trivia(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_trivia(&kind._from_ffi()) + } + + fn is_valid(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_valid(&kind._from_ffi()) + } +} + //================================================ // // enum edge-label @@ -53,6 +73,22 @@ enum_to_enum!(TerminalKind); enum_to_enum!(EdgeLabel); +//================================================ +// +// 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()), + } + } +} + //================================================ // // resource nonterminal-node @@ -60,24 +96,32 @@ enum_to_enum!(EdgeLabel); //================================================ define_rc_wrapper! { NonterminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::NonterminalKind { self._borrow_ffi().kind._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { + fn text_length(&self) -> ffi::TextIndex { self._borrow_ffi().text_len._into_ffi() } - fn children(&self) -> Vec { - self._borrow_ffi().children.iter().map(|edge| edge.node.clone()._into_ffi()).collect() + fn children(&self) -> Vec { + self._borrow_ffi().children.iter().map(|edge| edge.clone()._into_ffi()).collect() } - 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 { + self._borrow_ffi().unparse() } - fn unparse(&self) -> String { - std::rc::Rc::clone(self._borrow_ffi()).unparse() + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() + } + + 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() } } } @@ -88,31 +132,43 @@ define_rc_wrapper! { NonterminalNode { //================================================ define_rc_wrapper! { TerminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::TerminalKind { self._borrow_ffi().kind._into_ffi() } - fn text(&self) -> String { - self._borrow_ffi().text.clone() + fn text_length(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { - rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + fn children(&self) -> Vec { + Vec::new() + } + + fn unparse(&self) -> String { + self._borrow_ffi().unparse() + } + + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() } } } //================================================ // -// variant node +// record edge // //================================================ -impl IntoFFI for rust::Node { +impl IntoFFI for rust::Edge { #[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()), + fn _into_ffi(self) -> ffi::Edge { + ffi::Edge { + label: self.label.map(|label| label._into_ffi()), + node: self.node._into_ffi(), } } } @@ -160,9 +216,8 @@ define_refcell_wrapper! { Cursor { self._borrow_ffi().text_range()._into_ffi() } - #[allow(clippy::cast_possible_truncation)] fn depth(&self) -> u32 { - self._borrow_ffi().depth() as u32 + self._borrow_ffi().depth().try_into().unwrap() } fn ancestors(&self) -> Vec { @@ -261,11 +316,10 @@ define_wrapper! { Query { impl IntoFFI for rust::QueryError { #[inline] fn _into_ffi(self) -> ffi::QueryError { - #[allow(clippy::cast_possible_truncation)] ffi::QueryError { message: self.message, - row: self.row as u32, - column: self.column as u32, + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } @@ -292,8 +346,7 @@ 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, + query_number: self.query_number.try_into().unwrap(), captures: self .captures .into_iter() @@ -309,27 +362,19 @@ impl IntoFFI for rust::QueryMatch { // //================================================ -impl IntoFFI for rust::TextIndex { +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, + utf8: self.utf8.try_into().unwrap(), + utf16: self.utf16.try_into().unwrap(), + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } -impl IntoFFI for &rust::TextIndex { - #[inline] - fn _into_ffi(self) -> ffi::TextIndex { - (*self)._into_ffi() - } -} - -impl FromFFI for ffi::TextIndex { +impl FromFFI for &ffi::TextIndex { #[inline] fn _from_ffi(self) -> rust::TextIndex { rust::TextIndex { @@ -347,16 +392,6 @@ impl FromFFI for ffi::TextIndex { // //================================================ -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 { @@ -367,7 +402,7 @@ impl IntoFFI for &rust::TextRange { } } -impl FromFFI for ffi::TextRange { +impl FromFFI for &ffi::TextRange { #[inline] fn _from_ffi(self) -> rust::TextRange { rust::TextRange { diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/mod.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/mod.rs similarity index 56% rename from crates/codegen/runtime/cargo/src/runtime/wit/wrappers/mod.rs rename to crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/mod.rs index 55ba2199ca..26cb73d858 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/mod.rs +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/mod.rs @@ -1,3 +1,3 @@ +mod ast; mod cst; -mod diagnostic; mod parser; diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/parser.rs b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/parser/mod.rs similarity index 51% rename from crates/codegen/runtime/cargo/src/runtime/wit/wrappers/parser.rs rename to crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/parser/mod.rs index 535bb8a9eb..4add8de247 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/wrappers/parser.rs +++ b/crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/parser/mod.rs @@ -1,22 +1,20 @@ -use crate::diagnostic::Diagnostic; -use crate::wit::utils::{define_wrapper, FromFFI, IntoFFI}; +use crate::wasm_crate::utils::{define_wrapper, FromFFI, IntoFFI}; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ Cursor, Node, TextRange, }; - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; - pub use crate::wit::interface::exports::nomic_foundation::slang::parser::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::parser::{ Guest, GuestParseError, GuestParseOutput, GuestParser, NonterminalKind, ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Parser, ParserBorrow, }; } mod rust { - pub use crate::parser::{ParseError, ParseOutput, Parser}; + pub use crate::rust_crate::parser::{ParseError, ParseOutput, Parser}; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { type Parser = ParserWrapper; type ParseError = ParseErrorWrapper; type ParseOutput = ParseOutputWrapper; @@ -29,15 +27,8 @@ impl ffi::Guest for crate::wit::World { //================================================ define_wrapper! { Parser { - fn new(version: String) -> Result { - semver::Version::parse(&version) - .map_err(|_| format!("Invalid version: {version}")) - .and_then(|version| rust::Parser::new(version).map_err(|e| e.to_string())) - .map(IntoFFI::_into_ffi) - } - - fn version(&self) -> String { - self._borrow_ffi().version.to_string() + fn root_kind() -> ffi::NonterminalKind { + rust::Parser::ROOT_KIND._into_ffi() } fn supported_versions() -> Vec { @@ -47,6 +38,17 @@ define_wrapper! { Parser { .collect() } + fn create(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid semantic version: '{version}'")) + .and_then(|version| rust::Parser::create(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() } @@ -59,17 +61,13 @@ define_wrapper! { Parser { //================================================ 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 text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } - fn message(&self) -> String { - self._borrow_ffi().message() - } + fn message(&self) -> String { + self._borrow_ffi().message() + } } } //================================================ @@ -79,19 +77,19 @@ define_wrapper! { ParseError { //================================================ define_wrapper! { ParseOutput { - fn tree(&self) -> ffi::Node { - self._borrow_ffi().tree()._into_ffi() - } + 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 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 is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } - fn create_tree_cursor(&self) -> ffi::Cursor { - self._borrow_ffi().create_tree_cursor()._into_ffi() - } + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } } } diff --git a/crates/codegen/runtime/generator/src/lib.rs b/crates/codegen/runtime/generator/src/lib.rs index 254711c544..9ff2ba898d 100644 --- a/crates/codegen/runtime/generator/src/lib.rs +++ b/crates/codegen/runtime/generator/src/lib.rs @@ -4,7 +4,7 @@ mod kinds; mod parser; use std::collections::BTreeSet; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::rc::Rc; use anyhow::Result; @@ -19,42 +19,34 @@ use crate::bindings::BindingsModel; use crate::kinds::KindsModel; use crate::parser::ParserModel; -pub enum OutputLanguage { - Cargo, - Npm, -} +pub struct RuntimeGenerator; -impl OutputLanguage { - pub fn generate_runtime(&self, language: &Rc, output_dir: &Path) -> Result<()> { +impl RuntimeGenerator { + pub fn generate_product( + language: &Rc, + input_dir: &Path, + output_dir: &Path, + ) -> Result<()> { let model = ModelWrapper { rendering_in_stubs: false, model: RuntimeModel::from_language(language)?, }; - let mut runtime = CodegenRuntime::new(self.source_dir()?)?; + let mut runtime = CodegenRuntime::new(input_dir)?; - runtime.render_directory(model, output_dir) + runtime.render_product(model, output_dir) } - pub fn generate_stubs(&self) -> Result<()> { + pub fn generate_stubs(source_dir: &Path) -> Result<()> { let model = ModelWrapper { rendering_in_stubs: true, model: RuntimeModel::default(), }; - let mut runtime = CodegenRuntime::new(self.source_dir()?)?; + let mut runtime = CodegenRuntime::new(source_dir)?; runtime.render_stubs(&model) } - - fn source_dir(&self) -> Result { - let crate_name = match self { - Self::Cargo => "codegen_runtime_cargo", - Self::Npm => "codegen_runtime_npm", - }; - - Ok(CargoWorkspace::locate_source_crate(crate_name)?.join("src/runtime")) - } } /// A utility wrapper to make it easier to write conditional code in templates @@ -79,7 +71,7 @@ struct RuntimeModel { } impl RuntimeModel { - pub fn from_language(language: &Rc) -> Result { + fn from_language(language: &Rc) -> Result { Ok(Self { slang_version: CargoWorkspace::local_version()?, all_language_versions: language.versions.iter().cloned().collect(), diff --git a/crates/codegen/runtime/node_addon/Cargo.toml b/crates/codegen/runtime/node_addon/Cargo.toml deleted file mode 100644 index 2649c5b949..0000000000 --- a/crates/codegen/runtime/node_addon/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "codegen_runtime_node_addon" -version.workspace = true -rust-version.workspace = true -edition.workspace = true -publish = false - -# At the time of writing, building cdylib/plugins with Cargo has limited support -# (see for the general tracking issue). -# To workaround some of the issues, we create a synthetic crate that shares the same code as the original Rust crate -# but only exposes a `cdylib` library. -# There are a couple of things at play here: -# - To build a Node addon, we need to build a standalone cdylib, that's set up to expect host `napi_*` functions at runtime -# - `napi build` does that for us but only supports `cdylib` for the `lib` targets (e.g. not bin/examples) -# - expansion of #[napi] macros is enabled behind a feature flag; it expands the code that expects the host functions -# - while `napi/noop` feature exists that disables that, we test in workspace with `--all-features` and Cargo features are additive -# - thus, they get conflated and so the regular `rlib` library target gets built with the host functions expectation -# - ...which reasonably fails to link when `rlib` library is used as a regular Rust library (i.e. not in Node environment). -# Another workaround is to use an example with `cdylib` crate-type (wouldn't conflate the features in a downstream usable -# library), but napi doesn't support that yet. -# Also see for a similar issue with PyO3. -[lib] -path = "../cargo/src/lib.rs" -crate-type = ["cdylib"] - -# __RUST_NAPI_CRATE_FEATURES__ (keep in sync) -[features] -default = ["__private_napi_interfaces"] -__private_napi_interfaces = [ - # This enables '#[napi]' attributes on the Rust types imported via [lib.path] above. - "dep:serde_json", -] - -[build-dependencies] -napi-build = { workspace = true } - -[dependencies] -metaslang_cst = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } -semver = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true, optional = true } -strum = { workspace = true } -strum_macros = { workspace = true } -thiserror = { workspace = true } - -[lints] -workspace = true diff --git a/crates/codegen/runtime/node_addon/build.rs b/crates/codegen/runtime/node_addon/build.rs deleted file mode 100644 index bb9898efca..0000000000 --- a/crates/codegen/runtime/node_addon/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[cfg(not(feature = "__private_napi_interfaces"))] -compile_error!("The whole point is to enable __private_napi_interfaces for this cdylib crate!"); - -fn main() { - napi_build::setup(); -} diff --git a/crates/codegen/runtime/npm/build.rs b/crates/codegen/runtime/npm/build.rs deleted file mode 100644 index 12cb8a6e02..0000000000 --- a/crates/codegen/runtime/npm/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; - -fn main() -> Result<()> { - OutputLanguage::Npm.generate_stubs() -} diff --git a/crates/codegen/runtime/npm/package.json b/crates/codegen/runtime/npm/package.json deleted file mode 100644 index b6f007c4c1..0000000000 --- a/crates/codegen/runtime/npm/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "@slang-private/slang-codegen-runtime", - "private": true, - "type": "commonjs", - "devDependencies": { - "@napi-rs/cli": "2.18.4" - }, - "napi": { - "triples": { - "defaults": false, - "additional": [] - } - }, - "engines": { - "node": ">= 10" - } -} diff --git a/crates/codegen/runtime/npm/package/.gitignore b/crates/codegen/runtime/npm/package/.gitignore new file mode 100644 index 0000000000..53571f1f92 --- /dev/null +++ b/crates/codegen/runtime/npm/package/.gitignore @@ -0,0 +1,3 @@ +# WASM binaries and bindgen files generated during the build: +wasm/generated/*.js +wasm/generated/*.wasm diff --git a/crates/codegen/runtime/npm/CHANGELOG.md b/crates/codegen/runtime/npm/package/CHANGELOG.md similarity index 100% rename from crates/codegen/runtime/npm/CHANGELOG.md rename to crates/codegen/runtime/npm/package/CHANGELOG.md diff --git a/crates/codegen/runtime/npm/Cargo.toml b/crates/codegen/runtime/npm/package/Cargo.toml similarity index 80% rename from crates/codegen/runtime/npm/Cargo.toml rename to crates/codegen/runtime/npm/package/Cargo.toml index 2ac6009edc..1c243273e6 100644 --- a/crates/codegen/runtime/npm/Cargo.toml +++ b/crates/codegen/runtime/npm/package/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "codegen_runtime_npm" +name = "codegen_runtime_npm_package" version.workspace = true rust-version.workspace = true edition.workspace = true @@ -9,6 +9,7 @@ description = "TypeScript runtime copied over by codegen" [build-dependencies] anyhow = { workspace = true } +infra_utils = { workspace = true } codegen_runtime_generator = { workspace = true } [lints] diff --git a/crates/codegen/runtime/npm/LICENSE b/crates/codegen/runtime/npm/package/LICENSE similarity index 100% rename from crates/codegen/runtime/npm/LICENSE rename to crates/codegen/runtime/npm/package/LICENSE diff --git a/crates/codegen/runtime/npm/README.md b/crates/codegen/runtime/npm/package/README.md similarity index 100% rename from crates/codegen/runtime/npm/README.md rename to crates/codegen/runtime/npm/package/README.md diff --git a/crates/codegen/runtime/npm/package/build.rs b/crates/codegen/runtime/npm/package/build.rs new file mode 100644 index 0000000000..ec15e5de3a --- /dev/null +++ b/crates/codegen/runtime/npm/package/build.rs @@ -0,0 +1,9 @@ +use anyhow::Result; +use codegen_runtime_generator::RuntimeGenerator; +use infra_utils::cargo::CargoWorkspace; + +fn main() -> Result<()> { + let source_dir = CargoWorkspace::locate_source_crate("codegen_runtime_npm_package")?; + + RuntimeGenerator::generate_stubs(&source_dir) +} diff --git a/crates/codegen/runtime/npm/package/package.json b/crates/codegen/runtime/npm/package/package.json new file mode 100644 index 0000000000..f24c635db9 --- /dev/null +++ b/crates/codegen/runtime/npm/package/package.json @@ -0,0 +1,16 @@ +{ + "name": "@slang-private/codegen-runtime-npm-package", + "private": true, + "type": "module", + "__exports_comment__": "__SLANG_NPM_PACKAGE_EXPORTS__ (keep in sync)", + "exports": { + ".": "./target/generated/index.mjs", + "./ast": "./target/generated/ast/index.mjs", + "./cst": "./target/generated/cst/index.mjs", + "./parser": "./target/generated/parser/index.mjs" + }, + "__dependencies_comment__": "__SLANG_NPM_PACKAGE_DEPENDENCIES__ (keep in sync)", + "dependencies": { + "@bytecodealliance/preview2-shim": "0.17.0" + } +} diff --git a/crates/codegen/runtime/npm/src/lib.rs b/crates/codegen/runtime/npm/package/src/lib.rs similarity index 100% rename from crates/codegen/runtime/npm/src/lib.rs rename to crates/codegen/runtime/npm/package/src/lib.rs diff --git a/crates/codegen/runtime/npm/src/runtime/ast/generated/ast_types.ts b/crates/codegen/runtime/npm/package/src/runtime/ast/generated/nodes.mts similarity index 100% rename from crates/codegen/runtime/npm/src/runtime/ast/generated/ast_types.ts rename to crates/codegen/runtime/npm/package/src/runtime/ast/generated/nodes.mts diff --git a/crates/codegen/runtime/npm/package/src/runtime/ast/index.mts b/crates/codegen/runtime/npm/package/src/runtime/ast/index.mts new file mode 100644 index 0000000000..b7f19b4020 --- /dev/null +++ b/crates/codegen/runtime/npm/package/src/runtime/ast/index.mts @@ -0,0 +1 @@ +export * from "./generated/nodes.mjs"; diff --git a/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 b/crates/codegen/runtime/npm/package/src/runtime/ast/nodes.mts.jinja2 similarity index 84% rename from crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 rename to crates/codegen/runtime/npm/package/src/runtime/ast/nodes.mts.jinja2 index 918a2e41b0..95b422e017 100644 --- a/crates/codegen/runtime/npm/src/runtime/ast/ast_types.ts.jinja2 +++ b/crates/codegen/runtime/npm/package/src/runtime/ast/nodes.mts.jinja2 @@ -1,9 +1,8 @@ {%- if rendering_in_stubs -%} export class StubAst {} {%- else -%} - import * as assert from "node:assert"; - import { ast_internal } from "../../napi-bindings/generated"; - import { NodeType, NonterminalKind, NonterminalNode, TerminalNode } from "../../cst"; + import * as generated from "../../../../wasm/index.mjs"; + import { NonterminalKind, NonterminalNode, TerminalNode } from "../../cst/index.mjs"; /* * Sequences: @@ -16,13 +15,13 @@ {%- for field in sequence.fields %} ${{ field.label | camel_case }}, {%- endfor %} - ] = ast_internal.selectSequence(this.cst); + ] = generated.ast.Selectors.sequence(this.cst); return { {%- for field in sequence.fields %} {{ field.label | camel_case }}: {%- if field.is_optional -%} - ${{ field.label | camel_case }} === null ? undefined : + ${{ field.label | camel_case }} === undefined ? undefined : {%- endif -%} {%- if field.type -%} new {{ field.type }}(${{ field.label | camel_case }} as NonterminalNode), @@ -67,14 +66,14 @@ {%- set variant_types = variant_types | join(sep = " | ") -%} private readonly fetch: () => {{ variant_types }} = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); {% if choice.nonterminal_types | length == 0 -%} return variant as TerminalNode; {%- else -%} {% if choice.includes_terminals -%} - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } {%- endif %} @@ -85,7 +84,7 @@ {%- endfor %} default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } {%- endif %} }); @@ -107,7 +106,7 @@ {% for repeated in model.ast.repeated %} export class {{ repeated.parent_type }} { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); {%- if repeated.item_type -%} return items.map((item) => new {{ repeated.item_type }}(item as NonterminalNode)); @@ -139,11 +138,11 @@ {% for separated in model.ast.separated %} export class {{ separated.parent_type }} { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { {%- if separated.item_type -%} - items: items.map((item) => new {{ separated.item_type }}(item as NonterminalNode)), + items: items!.map((item) => new {{ separated.item_type }}(item as NonterminalNode)), {%- else -%} items: items as TerminalNode[], {%- endif -%} @@ -186,6 +185,8 @@ } function assertKind(actual: NonterminalKind, expected: NonterminalKind): void { - assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); + if (actual !== expected) { + throw new Error(`AST node '${expected}' can only be initialized with a CST node of the same kind. Received '${actual}' instead.`); + } } {%- endif %} diff --git a/crates/codegen/runtime/npm/package/src/runtime/cst/index.mts b/crates/codegen/runtime/npm/package/src/runtime/cst/index.mts new file mode 100644 index 0000000000..227042d491 --- /dev/null +++ b/crates/codegen/runtime/npm/package/src/runtime/cst/index.mts @@ -0,0 +1,79 @@ +import * as generated from "../../../wasm/index.mjs"; + +export const NonterminalKind = generated.cst.NonterminalKind; +export type NonterminalKind = generated.cst.NonterminalKind; + +export const TerminalKind = generated.cst.TerminalKind; +export type TerminalKind = generated.cst.TerminalKind; + +export const TerminalKindExtensions = generated.cst.TerminalKindExtensions; +export type TerminalKindExtensions = generated.cst.TerminalKindExtensions; + +export const EdgeLabel = generated.cst.EdgeLabel; +export type EdgeLabel = generated.cst.EdgeLabel; + +export type Node = generated.cst.Node; + +export const NodeVariant = generated.cst.NodeVariant; +export type NodeVariant = generated.cst.NodeVariant; + +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; + +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; + +export type Edge = generated.cst.Edge; + +export const Cursor = generated.cst.Cursor; +export type Cursor = generated.cst.Cursor; + +export const Query = generated.cst.Query; +export type Query = generated.cst.Query; + +export type QueryError = generated.cst.QueryError; + +export type QueryMatch = generated.cst.QueryMatch; + +export const QueryMatchIterator = generated.cst.QueryMatchIterator; +export type QueryMatchIterator = generated.cst.QueryMatchIterator; + +export type TextIndex = generated.cst.TextIndex; + +export type TextRange = generated.cst.TextRange; + +/* + * Helpers: + */ + +export function assertIsNonterminalNode( + node: unknown, + kind?: NonterminalKind, + text?: string, +): asserts node is NonterminalNode { + if (!(node instanceof NonterminalNode)) { + throw new Error("Node provided is not a NonterminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's NonterminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} + +export function assertIsTerminalNode(node: unknown, kind?: TerminalKind, text?: string): asserts node is TerminalNode { + if (!(node instanceof TerminalNode)) { + throw new Error("Node provided is not a TerminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's TerminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} diff --git a/crates/codegen/runtime/npm/package/src/runtime/index.mts b/crates/codegen/runtime/npm/package/src/runtime/index.mts new file mode 100644 index 0000000000..92781586e8 --- /dev/null +++ b/crates/codegen/runtime/npm/package/src/runtime/index.mts @@ -0,0 +1,3 @@ +export * as ast from "./ast/index.mjs"; +export * as cst from "./cst/index.mjs"; +export * as parser from "./parser/index.mjs"; diff --git a/crates/codegen/runtime/npm/src/runtime/parser/index.ts b/crates/codegen/runtime/npm/package/src/runtime/parser/index.mts similarity index 55% rename from crates/codegen/runtime/npm/src/runtime/parser/index.ts rename to crates/codegen/runtime/npm/package/src/runtime/parser/index.mts index 695007ce4a..ce780ebd2d 100644 --- a/crates/codegen/runtime/npm/src/runtime/parser/index.ts +++ b/crates/codegen/runtime/npm/package/src/runtime/parser/index.mts @@ -1,5 +1,4 @@ -import * as generated from "../napi-bindings/generated"; -import { DiagnosticInterface } from "../diagnostic"; +import * as generated from "../../../wasm/index.mjs"; export const Parser = generated.parser.Parser; export type Parser = generated.parser.Parser; @@ -7,8 +6,5 @@ export type Parser = generated.parser.Parser; export const ParseError = generated.parser.ParseError; export type ParseError = generated.parser.ParseError; -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; - export const ParseOutput = generated.parser.ParseOutput; export type ParseOutput = generated.parser.ParseOutput; diff --git a/crates/codegen/runtime/npm/package/tsconfig.json b/crates/codegen/runtime/npm/package/tsconfig.json new file mode 100644 index 0000000000..7b4d9a1ad1 --- /dev/null +++ b/crates/codegen/runtime/npm/package/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../../../tsconfig.json", + + "include": ["./**/*"], + + "compilerOptions": { + /* Projects */ + "composite": true, + "incremental": true, + "tsBuildInfoFile": "target/tsc/.tsbuildinfo" + } +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/codegen_runtime_cargo_wasm.component.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/codegen_runtime_cargo_wasm.component.d.ts new file mode 100644 index 0000000000..237bb59193 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/codegen_runtime_cargo_wasm.component.d.ts @@ -0,0 +1,18 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +import { WasiCliEnvironment } from "./interfaces/wasi-cli-environment.js"; +import { WasiCliExit } from "./interfaces/wasi-cli-exit.js"; +import { WasiCliStderr } from "./interfaces/wasi-cli-stderr.js"; +import { WasiCliStdin } from "./interfaces/wasi-cli-stdin.js"; +import { WasiCliStdout } from "./interfaces/wasi-cli-stdout.js"; +import { WasiClocksWallClock } from "./interfaces/wasi-clocks-wall-clock.js"; +import { WasiFilesystemPreopens } from "./interfaces/wasi-filesystem-preopens.js"; +import { WasiFilesystemTypes } from "./interfaces/wasi-filesystem-types.js"; +import { WasiIoError } from "./interfaces/wasi-io-error.js"; +import { WasiIoStreams } from "./interfaces/wasi-io-streams.js"; +import { NomicFoundationSlangCst } from "./interfaces/nomic-foundation-slang-cst.js"; +import { NomicFoundationSlangAst } from "./interfaces/nomic-foundation-slang-ast.js"; +import { NomicFoundationSlangParser } from "./interfaces/nomic-foundation-slang-parser.js"; +export * as cst from "./interfaces/nomic-foundation-slang-cst.js"; +export * as ast from "./interfaces/nomic-foundation-slang-ast.js"; +export * as parser from "./interfaces/nomic-foundation-slang-parser.js"; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts new file mode 100644 index 0000000000..138e7f7f89 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts @@ -0,0 +1,16 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangAst { + export { Selectors }; +} +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalNode } from "./nomic-foundation-slang-cst.js"; +export { NonterminalNode }; + +export class Selectors { + static sequence(node: NonterminalNode): (Node | undefined)[]; + static choice(node: NonterminalNode): Node; + static repeated(node: NonterminalNode): Node[]; + static separated(node: NonterminalNode): Node[][]; +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts new file mode 100644 index 0000000000..12cc9db232 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts @@ -0,0 +1,147 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangCst { + export { TerminalKindExtensions }; + export { NonterminalNode }; + export { TerminalNode }; + export { Cursor }; + export { Query }; + export { QueryMatchIterator }; + export { NonterminalKind }; + export { TerminalKind }; + export { EdgeLabel }; + export { Node }; + export { NodeVariant }; +} +export declare enum NonterminalKind { + Stub1 = "Stub1", + Stub2 = "Stub2", + Stub3 = "Stub3", +} +export declare enum TerminalKind { + Unrecognized = "Unrecognized", + Missing = "Missing", + Stub1 = "Stub1", + Stub2 = "Stub2", + Stub3 = "Stub3", +} +export declare enum EdgeLabel { + Item = "Item", + Variant = "Variant", + Separator = "Separator", + Operand = "Operand", + LeftOperand = "LeftOperand", + RightOperand = "RightOperand", + LeadingTrivia = "LeadingTrivia", + TrailingTrivia = "TrailingTrivia", + Stub1 = "Stub1", + Stub2 = "Stub2", + Stub3 = "Stub3", +} +export type Node = NonterminalNode | TerminalNode; +export enum NodeVariant { + NonterminalNode = "NonterminalNode", + TerminalNode = "TerminalNode", +} +export interface Edge { + label?: EdgeLabel; + node: Node; +} +export interface QueryError { + message: string; + line: number; + column: number; +} +export interface QueryMatch { + queryNumber: number; + captures: { [key: string]: Cursor[] }; +} +export interface TextIndex { + utf8: number; + utf16: number; + line: number; + column: number; +} +export interface TextRange { + start: TextIndex; + end: TextIndex; +} + +export class Cursor { + reset(): void; + complete(): void; + isCompleted(): boolean; + clone(): Cursor; + spawn(): Cursor; + get node(): Node; + get label(): EdgeLabel | undefined; + get textOffset(): TextIndex; + get textRange(): TextRange; + get depth(): number; + get ancestors(): NonterminalNode[]; + goToNext(): boolean; + goToNextNonDescendent(): boolean; + goToPrevious(): boolean; + goToParent(): boolean; + goToFirstChild(): boolean; + goToLastChild(): boolean; + goToNthChild(childNumber: number): boolean; + goToNextSibling(): boolean; + goToPreviousSibling(): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: TerminalKind): boolean; + goToNextTerminalWithKinds(kinds: TerminalKind[]): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: NonterminalKind[]): boolean; + query(queries: Query[]): QueryMatchIterator; +} + +export class NonterminalNode { + readonly nodeVariant = NodeVariant.NonterminalNode; + + asNonterminalNode(): this; + isNonterminalNode(): this is NonterminalNode; + + asTerminalNode(): undefined; + isTerminalNode(): false; + + get id(): number; + get kind(): NonterminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; + createCursor(textOffset: TextIndex): Cursor; +} + +export class Query { + static parse(text: string): Query; +} + +export class QueryMatchIterator { + [Symbol.iterator](): Iterator; + next(): QueryMatch | undefined; +} + +export class TerminalKindExtensions { + static isTrivia(kind: TerminalKind): boolean; + static isValid(kind: TerminalKind): boolean; +} + +export class TerminalNode { + readonly nodeVariant = NodeVariant.TerminalNode; + + asTerminalNode(): this; + isTerminalNode(): this is TerminalNode; + + asNonterminalNode(): undefined; + isNonterminalNode(): false; + + get id(): number; + get kind(): TerminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts new file mode 100644 index 0000000000..c759bea9a5 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts @@ -0,0 +1,35 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangParser { + export { Parser }; + export { ParseError }; + export { ParseOutput }; +} +import type { Cursor } from "./nomic-foundation-slang-cst.js"; +export { Cursor }; +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalKind } from "./nomic-foundation-slang-cst.js"; +export { NonterminalKind }; +import type { TextRange } from "./nomic-foundation-slang-cst.js"; +export { TextRange }; + +export class ParseError { + get textRange(): TextRange; + get message(): string; +} + +export class ParseOutput { + get tree(): Node; + get errors(): ParseError[]; + isValid(): boolean; + createTreeCursor(): Cursor; +} + +export class Parser { + static rootKind(): NonterminalKind; + static supportedVersions(): string[]; + static create(version: string): Parser; + get version(): string; + parse(kind: NonterminalKind, input: string): ParseOutput; +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts new file mode 100644 index 0000000000..2e7e18e20c --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts @@ -0,0 +1,5 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliEnvironment { + export function getEnvironment(): [string, string][]; +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts new file mode 100644 index 0000000000..00e416f2a9 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliExit { + export function exit(status: Result): void; +} +export type Result = { tag: "ok"; val: T } | { tag: "err"; val: E }; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts new file mode 100644 index 0000000000..58b90e29bf --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStderr { + export function getStderr(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts new file mode 100644 index 0000000000..e5f574f5bd --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdin { + export function getStdin(): InputStream; +} +import type { InputStream } from "./wasi-io-streams.js"; +export { InputStream }; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts new file mode 100644 index 0000000000..49023013c5 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdout { + export function getStdout(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts new file mode 100644 index 0000000000..ea190faee8 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiClocksWallClock {} +export interface Datetime { + seconds: bigint; + nanoseconds: number; +} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts new file mode 100644 index 0000000000..7c94c88da2 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemPreopens { + export function getDirectories(): [Descriptor, string][]; +} +import type { Descriptor } from "./wasi-filesystem-types.js"; +export { Descriptor }; diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts new file mode 100644 index 0000000000..140b5f4bac --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts @@ -0,0 +1,172 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemTypes { + export { Descriptor }; + export function filesystemErrorCode(err: Error): ErrorCode | undefined; +} +export type Filesize = bigint; +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; +/** + * # Variants + * + * ## `"access"` + * + * ## `"would-block"` + * + * ## `"already"` + * + * ## `"bad-descriptor"` + * + * ## `"busy"` + * + * ## `"deadlock"` + * + * ## `"quota"` + * + * ## `"exist"` + * + * ## `"file-too-large"` + * + * ## `"illegal-byte-sequence"` + * + * ## `"in-progress"` + * + * ## `"interrupted"` + * + * ## `"invalid"` + * + * ## `"io"` + * + * ## `"is-directory"` + * + * ## `"loop"` + * + * ## `"too-many-links"` + * + * ## `"message-size"` + * + * ## `"name-too-long"` + * + * ## `"no-device"` + * + * ## `"no-entry"` + * + * ## `"no-lock"` + * + * ## `"insufficient-memory"` + * + * ## `"insufficient-space"` + * + * ## `"not-directory"` + * + * ## `"not-empty"` + * + * ## `"not-recoverable"` + * + * ## `"unsupported"` + * + * ## `"no-tty"` + * + * ## `"no-such-device"` + * + * ## `"overflow"` + * + * ## `"not-permitted"` + * + * ## `"pipe"` + * + * ## `"read-only"` + * + * ## `"invalid-seek"` + * + * ## `"text-file-busy"` + * + * ## `"cross-device"` + */ +export type ErrorCode = + | "access" + | "would-block" + | "already" + | "bad-descriptor" + | "busy" + | "deadlock" + | "quota" + | "exist" + | "file-too-large" + | "illegal-byte-sequence" + | "in-progress" + | "interrupted" + | "invalid" + | "io" + | "is-directory" + | "loop" + | "too-many-links" + | "message-size" + | "name-too-long" + | "no-device" + | "no-entry" + | "no-lock" + | "insufficient-memory" + | "insufficient-space" + | "not-directory" + | "not-empty" + | "not-recoverable" + | "unsupported" + | "no-tty" + | "no-such-device" + | "overflow" + | "not-permitted" + | "pipe" + | "read-only" + | "invalid-seek" + | "text-file-busy" + | "cross-device"; +/** + * # Variants + * + * ## `"unknown"` + * + * ## `"block-device"` + * + * ## `"character-device"` + * + * ## `"directory"` + * + * ## `"fifo"` + * + * ## `"symbolic-link"` + * + * ## `"regular-file"` + * + * ## `"socket"` + */ +export type DescriptorType = + | "unknown" + | "block-device" + | "character-device" + | "directory" + | "fifo" + | "symbolic-link" + | "regular-file" + | "socket"; +export type LinkCount = bigint; +import type { Datetime } from "./wasi-clocks-wall-clock.js"; +export { Datetime }; +export interface DescriptorStat { + type: DescriptorType; + linkCount: LinkCount; + size: Filesize; + dataAccessTimestamp?: Datetime; + dataModificationTimestamp?: Datetime; + statusChangeTimestamp?: Datetime; +} +import type { Error } from "./wasi-io-streams.js"; +export { Error }; + +export class Descriptor { + writeViaStream(offset: Filesize): OutputStream; + appendViaStream(): OutputStream; + getType(): DescriptorType; + stat(): DescriptorStat; +} diff --git a/crates/solidity/outputs/npm/package/src/generated/ast/index.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts similarity index 55% rename from crates/solidity/outputs/npm/package/src/generated/ast/index.ts rename to crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts index e92970e319..f52a8b4cc5 100644 --- a/crates/solidity/outputs/npm/package/src/generated/ast/index.ts +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts @@ -1,3 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -export * from "./generated/ast_types"; +export namespace WasiIoError { + export { Error }; +} + +export class Error {} diff --git a/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts new file mode 100644 index 0000000000..fc56e10c39 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts @@ -0,0 +1,25 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiIoStreams { + export { OutputStream }; + export { InputStream }; +} +import type { Error } from "./wasi-io-error.js"; +export { Error }; +export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed; +export interface StreamErrorLastOperationFailed { + tag: "last-operation-failed"; + val: Error; +} +export interface StreamErrorClosed { + tag: "closed"; +} + +export class InputStream {} + +export class OutputStream { + checkWrite(): bigint; + write(contents: Uint8Array): void; + blockingWriteAndFlush(contents: Uint8Array): void; + blockingFlush(): void; +} diff --git a/crates/codegen/runtime/npm/package/wasm/index.mts b/crates/codegen/runtime/npm/package/wasm/index.mts new file mode 100644 index 0000000000..66f095e092 --- /dev/null +++ b/crates/codegen/runtime/npm/package/wasm/index.mts @@ -0,0 +1 @@ +export * from "./generated/codegen_runtime_cargo_wasm.component.js"; diff --git a/crates/codegen/runtime/npm/src/runtime/ast/index.ts b/crates/codegen/runtime/npm/src/runtime/ast/index.ts deleted file mode 100644 index 9beacf3edb..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/ast/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./generated/ast_types"; diff --git a/crates/codegen/runtime/npm/src/runtime/cst/index.ts b/crates/codegen/runtime/npm/src/runtime/cst/index.ts deleted file mode 100644 index ef91e9d2a4..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/cst/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as generated from "../napi-bindings/generated"; - -export const NonterminalKind = generated.cst.NonterminalKind; -export type NonterminalKind = generated.cst.NonterminalKind; - -export const TerminalKind = generated.cst.TerminalKind; -export type TerminalKind = generated.cst.TerminalKind; - -export const EdgeLabel = generated.cst.EdgeLabel; -export type EdgeLabel = generated.cst.EdgeLabel; - -export type Node = generated.cst.Node; - -export const NodeType = generated.cst.NodeType; -export type NodeType = generated.cst.NodeType; - -export const NonterminalNode = generated.cst.NonterminalNode; -export type NonterminalNode = generated.cst.NonterminalNode; - -export const TerminalNode = generated.cst.TerminalNode; -export type TerminalNode = generated.cst.TerminalNode; - -export const Cursor = generated.cst.Cursor; -export type Cursor = generated.cst.Cursor; - -export const Query = generated.cst.Query; -export type Query = generated.cst.Query; - -export type QueryMatch = generated.cst.QueryMatch; - -export const QueryMatchIterator = generated.cst.QueryMatchIterator; -export type QueryMatchIterator = generated.cst.QueryMatchIterator; - -export type TextIndex = generated.cst.TextIndex; - -export type TextRange = generated.cst.TextRange; diff --git a/crates/codegen/runtime/npm/src/runtime/diagnostic/index.ts b/crates/codegen/runtime/npm/src/runtime/diagnostic/index.ts deleted file mode 100644 index 865a3a8221..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/diagnostic/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import * as generated from "../napi-bindings/generated"; - -export const Severity = generated.diagnostic.Severity; -export type Severity = generated.diagnostic.Severity; - -export const Diagnostic = generated.diagnostic.Diagnostic; -export type Diagnostic = generated.diagnostic.Diagnostic; - -// NOTE(#987): napi-rs does not allow us to either export traits as interfaces -// or interfaces with methods in general, so we define the interface ourselves. -export interface DiagnosticInterface { - textRange(): generated.cst.TextRange; - message(): string; - severity(): Severity; -} - -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; diff --git a/crates/codegen/runtime/npm/src/runtime/index.ts b/crates/codegen/runtime/npm/src/runtime/index.ts deleted file mode 100644 index 2b6cee6cf3..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * as ast from "./ast"; -export * as cst from "./cst"; -export * as parser from "./parser"; diff --git a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts b/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts deleted file mode 100644 index 6ed5262583..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.d.ts +++ /dev/null @@ -1,162 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -export declare namespace cst { - export enum NonterminalKind { - Stub1 = "Stub1", - Stub2 = "Stub2", - Stub3 = "Stub3", - } - export enum EdgeLabel { - Item = "Item", - Variant = "Variant", - Separator = "Separator", - Operand = "Operand", - LeftOperand = "LeftOperand", - RightOperand = "RightOperand", - LeadingTrivia = "LeadingTrivia", - TrailingTrivia = "TrailingTrivia", - Stub1 = "Stub1", - Stub2 = "Stub2", - Stub3 = "Stub3", - } - export enum TerminalKind { - UNRECOGNIZED = "UNRECOGNIZED", - MISSING = "MISSING", - Stub1 = "Stub1", - Stub2 = "Stub2", - Stub3 = "Stub3", - } - export enum NodeType { - Nonterminal = "Nonterminal", - Terminal = "Terminal", - } - export interface QueryMatch { - queryNumber: number; - captures: { [key: string]: cst.Cursor[] }; - } - export interface TextIndex { - utf8: number; - utf16: number; - line: number; - column: number; - } - export interface TextRange { - start: TextIndex; - end: TextIndex; - } - export class NonterminalNode { - get type(): cst.NodeType.Nonterminal; - get kind(): cst.NonterminalKind; - get textLength(): cst.TextIndex; - children(): Array; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - /** Serialize the node to JSON. */ - toJSON(): string; - unparse(): string; - } - export class TerminalNode { - get type(): cst.NodeType.Terminal; - get kind(): cst.TerminalKind; - get textLength(): cst.TextIndex; - get text(): string; - /** Serialize the node to JSON. */ - toJSON(): string; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - } - export class Cursor { - reset(): void; - complete(): void; - clone(): Cursor; - spawn(): Cursor; - get isCompleted(): boolean; - node(): cst.Node; - get label(): cst.EdgeLabel; - get textOffset(): cst.TextIndex; - get textRange(): cst.TextRange; - get depth(): number; - ancestors(): Array; - goToNext(): boolean; - goToNextNonDescendent(): boolean; - goToPrevious(): boolean; - goToParent(): boolean; - goToFirstChild(): boolean; - goToLastChild(): boolean; - goToNthChild(childNumber: number): boolean; - goToNextSibling(): boolean; - goToPreviousSibling(): boolean; - goToNextTerminal(): boolean; - goToNextTerminalWithKind(kind: cst.TerminalKind): boolean; - goToNextTerminalWithKinds(kinds: Array): boolean; - goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: cst.NonterminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; - query(queries: Array): cst.QueryMatchIterator; - } - export class Query { - static parse(text: string): Query; - } - export class QueryMatchIterator { - next(): QueryMatch | null; - } -} -export declare namespace parser { - export class Parser { - constructor(version: string); - get version(): string; - static supportedVersions(): Array; - static rootKind(): cst.NonterminalKind; - parse(kind: cst.NonterminalKind, input: string): parser.ParseOutput; - } - export class ParseError { - severity(): diagnostic.Severity; - textRange(): cst.TextRange; - message(): string; - } - export class ParseOutput { - tree(): cst.Node; - errors(): Array; - get isValid(): boolean; - /** Creates a cursor that starts at the root of the parse tree. */ - createTreeCursor(): cst.Cursor; - } -} -export declare namespace diagnostic { - /** - * Severity of the compiler diagnostic. - * - * Explicitly compatible with the LSP protocol. - */ - export enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, - } - /** A compiler diagnostic that can be rendered to a user. */ - export class Diagnostic { - /** The severity of this diagnostic. */ - severity(): Severity; - /** The character range of the source that this diagnostic applies to. */ - textRange(): cst.TextRange; - /** The primary message associated with this diagnostic. */ - message(): string; - } -} -export declare namespace ast_internal { - export function selectSequence(node: cst.NonterminalNode): Array; - export function selectChoice(node: cst.NonterminalNode): cst.Node; - export function selectRepeated(node: cst.NonterminalNode): Array; - export function selectSeparated(node: cst.NonterminalNode): [Array, Array]; -} - -export namespace cst { - export type Node = TerminalNode | NonterminalNode; -} diff --git a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.js b/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.js deleted file mode 100644 index 54ef035fb6..0000000000 --- a/crates/codegen/runtime/npm/src/runtime/napi-bindings/generated/index.js +++ /dev/null @@ -1,299 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -// @ts-nocheck - -/* tslint:disable */ -/* eslint-disable */ -/* prettier-ignore */ - -/* auto-generated by NAPI-RS */ - -const { existsSync, readFileSync } = require('fs') -const { join } = require("path"); - -const { platform, arch } = process; - -let nativeBinding = null; -let localFileExisted = false; -let loadError = null; - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== "function") { - try { - const lddPath = require("child_process").execSync("which ldd").toString().trim(); - return readFileSync(lddPath, "utf8").includes("musl"); - } catch (e) { - return true; - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header; - return !glibcVersionRuntime; - } -} - -switch (platform) { - case "android": - switch (arch) { - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.android-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm64.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-android-arm64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm": - localFileExisted = existsSync(join(__dirname, "index.android-arm-eabi.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm-eabi.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-android-arm-eabi"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Android ${arch}`); - } - break; - case "win32": - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.win32-x64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-x64-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-win32-x64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "ia32": - localFileExisted = existsSync(join(__dirname, "index.win32-ia32-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-ia32-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-win32-ia32-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.win32-arm64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-arm64-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-win32-arm64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`); - } - break; - case "darwin": - localFileExisted = existsSync(join(__dirname, "index.darwin-universal.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-universal.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-darwin-universal"); - } - break; - } catch {} - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.darwin-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-x64.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-darwin-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.darwin-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-arm64.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-darwin-arm64"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`); - } - break; - case "freebsd": - if (arch !== "x64") { - throw new Error(`Unsupported architecture on FreeBSD: ${arch}`); - } - localFileExisted = existsSync(join(__dirname, "index.freebsd-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.freebsd-x64.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-freebsd-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "linux": - switch (arch) { - case "x64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-x64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-x64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-arm64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-arm64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-musleabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-musleabihf.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-arm-musleabihf"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-gnueabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-gnueabihf.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-arm-gnueabihf"); - } - } catch (e) { - loadError = e; - } - } - break; - case "riscv64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-riscv64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-riscv64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "s390x": - localFileExisted = existsSync(join(__dirname, "index.linux-s390x-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-s390x-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-codegen-runtime-linux-s390x-gnu"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`); - } - break; - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); -} - -if (!nativeBinding) { - if (loadError) { - throw loadError; - } - throw new Error(`Failed to load native binding`); -} - -const { cst, parser, diagnostic, ast_internal } = nativeBinding; - -module.exports.cst = cst; -module.exports.parser = parser; -module.exports.diagnostic = diagnostic; -module.exports.ast_internal = ast_internal; diff --git a/crates/codegen/runtime/npm/tsconfig.json b/crates/codegen/runtime/npm/tsconfig.json deleted file mode 100644 index 2ad4db51a5..0000000000 --- a/crates/codegen/runtime/npm/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "../../../../tsconfig.json", - - "include": ["./src/**/*.ts"], - - "compilerOptions": { - /* Modules */ - "module": "CommonJS", - "moduleResolution": "Node", - "rootDir": "./src/runtime", - - /* Language and Environment */ - "target": "ES2016", - - /* Projects */ - "composite": true, - "incremental": true, - "tsBuildInfoFile": "target/tsc/.tsbuildinfo" - } -} diff --git a/crates/infra/cli/Cargo.toml b/crates/infra/cli/Cargo.toml index 60f7fcb881..b3291e1dd9 100644 --- a/crates/infra/cli/Cargo.toml +++ b/crates/infra/cli/Cargo.toml @@ -14,14 +14,12 @@ clap_complete = { workspace = true } infra_utils = { workspace = true } itertools = { workspace = true } markdown = { workspace = true } -regex = { workspace = true } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } strum = { workspace = true } strum_macros = { workspace = true } tempfile = { workspace = true } -tera = { workspace = true } toml = { workspace = true } [lints] diff --git a/crates/infra/cli/src/commands/check/mod.rs b/crates/infra/cli/src/commands/check/mod.rs index 957b9782a2..35ee967ceb 100644 --- a/crates/infra/cli/src/commands/check/mod.rs +++ b/crates/infra/cli/src/commands/check/mod.rs @@ -6,7 +6,7 @@ use infra_utils::terminal::Terminal; use strum::IntoEnumIterator; use crate::toolchains::mkdocs::Mkdocs; -use crate::toolchains::napi::{NapiCompiler, NapiProfile, NapiResolver}; +use crate::toolchains::wasm::WasmPackage; use crate::utils::{ClapExtensions, OrderedCommand}; #[derive(Clone, Debug, Default, Parser)] @@ -72,8 +72,8 @@ fn check_rustdoc() { } fn check_npm() -> Result<()> { - for resolver in NapiResolver::iter() { - NapiCompiler::run(resolver, NapiProfile::Debug)?; + for package in WasmPackage::iter() { + package.build()?; } Ok(()) diff --git a/crates/infra/cli/src/commands/publish/changesets/mod.rs b/crates/infra/cli/src/commands/publish/changesets/mod.rs index 032edd58f9..b1071544a8 100644 --- a/crates/infra/cli/src/commands/publish/changesets/mod.rs +++ b/crates/infra/cli/src/commands/publish/changesets/mod.rs @@ -3,10 +3,6 @@ //! //! So, we let changesets bump the version of the single NPM package we ship, and generate its changelog. //! Then our build process copies the new version and the single changelog to other packages and crates. -//! -//! Additionally, changesets can only bump versions of packages in the root workspace. -//! However, NAPI platform-specific packages cannot be added to the workspace, because other platforms will fail "npm install". -//! So we have to bump the versions over ourselves anyways. use anyhow::Result; use clap::Parser; @@ -14,7 +10,8 @@ use infra_utils::cargo::CargoWorkspace; use infra_utils::commands::Command; use infra_utils::paths::{FileWalker, PathExtensions}; -use crate::toolchains::napi::{NapiConfig, NapiResolver}; +use crate::toolchains::npm::Npm; +use crate::toolchains::wasm::WasmPackage; #[derive(Clone, Debug, Parser)] pub struct ChangesetsController {} @@ -22,10 +19,10 @@ pub struct ChangesetsController {} impl ChangesetsController { #[allow(clippy::unused_self)] // for compatibility with other controllers: pub fn execute(&self) -> Result<()> { - let resolver = NapiResolver::Solidity; - let package_dir = resolver.main_package_dir(); + let package = WasmPackage::Solidity; + let package_dir = CargoWorkspace::locate_source_crate(package.npm_crate())?; - let package_version = NapiConfig::local_version(&package_dir)?; + let package_version = Npm::local_version(&package_dir)?; println!("Package version: {package_version}"); let workspace_version = CargoWorkspace::local_version()?; @@ -43,7 +40,7 @@ impl ChangesetsController { Command::new("changeset").arg("version").run(); - let updated_version = NapiConfig::local_version(&package_dir)?; + let updated_version = Npm::local_version(&package_dir)?; println!("Updated version: {updated_version}"); if package_version == updated_version { @@ -53,7 +50,6 @@ impl ChangesetsController { // Format the updated package files: - let package_dir = resolver.main_package_dir(); Command::new("prettier") .property("--write", package_dir.unwrap_str()) .run(); diff --git a/crates/infra/cli/src/commands/publish/npm/mod.rs b/crates/infra/cli/src/commands/publish/npm/mod.rs index 395ea730fa..2f9e780a49 100644 --- a/crates/infra/cli/src/commands/publish/npm/mod.rs +++ b/crates/infra/cli/src/commands/publish/npm/mod.rs @@ -1,13 +1,11 @@ -use std::path::Path; - use anyhow::Result; use clap::Parser; +use infra_utils::cargo::CargoWorkspace; use infra_utils::commands::Command; use infra_utils::paths::PathExtensions; -use crate::toolchains::napi::{ - NapiCompiler, NapiConfig, NapiPackageKind, NapiProfile, NapiResolver, -}; +use crate::toolchains::npm::Npm; +use crate::toolchains::wasm::WasmPackage; use crate::utils::DryRun; #[derive(Clone, Debug, Parser)] @@ -18,59 +16,34 @@ pub struct NpmController { impl NpmController { pub fn execute(&self) -> Result<()> { - let resolver = NapiResolver::Solidity; - - NapiCompiler::run(resolver, NapiProfile::Release)?; + let package = WasmPackage::Solidity; + let package_dir = CargoWorkspace::locate_source_crate(package.npm_crate())?; - // Publish platform-specific packages first, as the main package now depends on their latest version: + package.build()?; - for platform_dir in resolver.platforms_dir().collect_children()? { - let platform = platform_dir.unwrap_name().to_owned(); - publish_package( - resolver, - &platform_dir, - &NapiPackageKind::Platform(platform), - self.dry_run, - )?; - } + println!("Publishing: {package_dir:?}"); - // Then publish the main package, that depends on the previously published platform-specific packages: + let local_version = Npm::local_version(&package_dir)?; + println!("Local version: {local_version}"); - let package_dir = resolver.main_package_dir(); - publish_package(resolver, &package_dir, &NapiPackageKind::Main, self.dry_run) - } -} - -fn publish_package( - resolver: NapiResolver, - package_dir: &Path, - kind: &NapiPackageKind, - dry_run: DryRun, -) -> Result<()> { - println!("Publishing: {package_dir:?}"); + let published_version = Npm::published_version(&package_dir)?; + println!("Published version: {published_version}"); - let local_version = NapiConfig::local_version(package_dir)?; - println!("Local version: {local_version}"); - - let published_version = NapiConfig::published_version(package_dir)?; - println!("Published version: {published_version}"); + if local_version == published_version { + println!("Skipping package, since the local version is already published."); + return Ok(()); + } - if local_version == published_version { - println!("Skipping package, since the local version is already published."); - return Ok(()); - } + let mut command = Command::new("npm") + .args(["publish", package_dir.unwrap_str()]) + .property("--access", "public"); - let output_dir = resolver.npm_output_dir(kind); + if self.dry_run.get() { + command = command.flag("--dry-run"); + } - let mut command = Command::new("npm") - .args(["publish", output_dir.unwrap_str()]) - .property("--access", "public"); + command.run(); - if dry_run.get() { - command = command.flag("--dry-run"); + Ok(()) } - - command.run(); - - Ok(()) } diff --git a/crates/infra/cli/src/commands/setup/cargo/mod.rs b/crates/infra/cli/src/commands/setup/cargo/mod.rs index e816ef5bb8..6bacb7433d 100644 --- a/crates/infra/cli/src/commands/setup/cargo/mod.rs +++ b/crates/infra/cli/src/commands/setup/cargo/mod.rs @@ -1,6 +1,8 @@ use infra_utils::commands::Command; use infra_utils::github::GitHub; +use crate::toolchains::wasm::WASM_TARGET; + pub fn setup_cargo() { // The bootstrap bash script defined in '$REPO_ROOT/scripts/_common.sh' // installs the 'minimal' profile of the '$RUST_STABLE_VERSION' toolchain. @@ -29,10 +31,21 @@ pub fn setup_cargo() { rustup_install_toolchain(env!("RUST_NIGHTLY_VERSION")); rustup_add_components(env!("RUST_NIGHTLY_VERSION"), ["rustfmt", "rust-docs"]); + // Needed for the TypeScript packages: + rustup_add_targets(env!("RUST_STABLE_VERSION"), [WASM_TARGET]); + // Make sure we have the latest dependencies: run_cargo_fetch(); } +fn rustup_add_targets(toolchain: &str, targets: impl IntoIterator>) { + Command::new("rustup") + .args(["target", "add"]) + .property("--toolchain", toolchain) + .args(targets) + .run(); +} + fn rustup_install_toolchain(toolchain: &str) { Command::new("rustup") .arg("install") diff --git a/crates/infra/cli/src/commands/setup/git/mod.rs b/crates/infra/cli/src/commands/setup/git/mod.rs index 39a1cf88a8..536d573c24 100644 --- a/crates/infra/cli/src/commands/setup/git/mod.rs +++ b/crates/infra/cli/src/commands/setup/git/mod.rs @@ -2,18 +2,21 @@ use infra_utils::commands::Command; use infra_utils::github::GitHub; pub fn setup_git() { - if !GitHub::is_running_in_ci() { - println!("No need to modify local dev environments."); - return; - } + if GitHub::is_running_in_ci() { + Command::new("git") + .arg("config") + .property("user.name", "github-actions") + .run(); - Command::new("git") - .arg("config") - .property("user.name", "github-actions") - .run(); + Command::new("git") + .arg("config") + .property("user.email", "github-actions@users.noreply.github.com") + .run(); + } Command::new("git") - .arg("config") - .property("user.email", "github-actions@users.noreply.github.com") + .args(["submodule", "update"]) + .flag("--init") + .flag("--progress") .run(); } diff --git a/crates/infra/cli/src/commands/setup/npm/mod.rs b/crates/infra/cli/src/commands/setup/npm/mod.rs index b999deecfd..6c985139c4 100644 --- a/crates/infra/cli/src/commands/setup/npm/mod.rs +++ b/crates/infra/cli/src/commands/setup/npm/mod.rs @@ -1,5 +1,8 @@ +use std::path::Path; + use infra_utils::commands::Command; use infra_utils::github::GitHub; +use infra_utils::paths::PathExtensions; pub fn setup_npm() { if GitHub::is_running_in_ci() { @@ -7,4 +10,19 @@ pub fn setup_npm() { } else { Command::new("npm").arg("install").run(); } + + Command::new("npm") + .current_dir(Path::repo_path("submodules/jco")) + .args(["install"]) + .run(); + + Command::new("npm") + .current_dir(Path::repo_path("submodules/jco")) + .args(["run", "build"]) + .run(); + + Command::new("npm") + .current_dir(Path::repo_path("submodules/jco")) + .args(["run", "build:release"]) + .run(); } diff --git a/crates/infra/cli/src/commands/test/mod.rs b/crates/infra/cli/src/commands/test/mod.rs index 37fbb59b1c..792a037d1e 100644 --- a/crates/infra/cli/src/commands/test/mod.rs +++ b/crates/infra/cli/src/commands/test/mod.rs @@ -57,5 +57,8 @@ fn test_cargo() -> Result<()> { } fn test_npm() { - Command::new("jest").run(); + Command::new("jest") + .env("NODE_OPTIONS", "--experimental-vm-modules") // because we are executing ESM tests + .env("NODE_NO_WARNINGS", "1") // disable warnings about experimental feature above (too much noise) + .run(); } diff --git a/crates/infra/cli/src/main.rs b/crates/infra/cli/src/main.rs index f7098d78e9..4566e6f216 100644 --- a/crates/infra/cli/src/main.rs +++ b/crates/infra/cli/src/main.rs @@ -2,13 +2,14 @@ mod commands; mod toolchains; mod utils; +use anyhow::Result; use clap::Parser; use infra_utils::terminal::Terminal; use crate::commands::Cli; -fn main() { - Terminal::wrap_execution(|| Cli::parse().execute()); +fn main() -> Result<()> { + Terminal::wrap_execution(|| Cli::parse().execute()) } #[test] diff --git a/crates/infra/cli/src/toolchains/mod.rs b/crates/infra/cli/src/toolchains/mod.rs index 4220506bae..2788558bcd 100644 --- a/crates/infra/cli/src/toolchains/mod.rs +++ b/crates/infra/cli/src/toolchains/mod.rs @@ -1,3 +1,4 @@ pub mod mkdocs; -pub mod napi; +pub mod npm; pub mod pipenv; +pub mod wasm; diff --git a/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 b/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 deleted file mode 100644 index 97986be7c3..0000000000 --- a/crates/infra/cli/src/toolchains/napi/bindings/index.d.ts.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -{# Automatically generated by NAPI: #} - -{{ contents }} - -{# Manual Additions: #} - -export namespace cst { - export type Node = TerminalNode | NonterminalNode; -} diff --git a/crates/infra/cli/src/toolchains/napi/bindings/index.js.jinja2 b/crates/infra/cli/src/toolchains/napi/bindings/index.js.jinja2 deleted file mode 100644 index 5e8c6b9b36..0000000000 --- a/crates/infra/cli/src/toolchains/napi/bindings/index.js.jinja2 +++ /dev/null @@ -1,12 +0,0 @@ -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -// @ts-nocheck - -{# Automatically generated by NAPI: #} - -{{ contents }} - -{# Manual Additions: #} - -{# Any manual additions should go here... #} diff --git a/crates/infra/cli/src/toolchains/napi/cli.rs b/crates/infra/cli/src/toolchains/napi/cli.rs deleted file mode 100644 index b6c8d9fb11..0000000000 --- a/crates/infra/cli/src/toolchains/napi/cli.rs +++ /dev/null @@ -1,102 +0,0 @@ -use std::path::{Path, PathBuf}; - -use anyhow::{bail, Context, Result}; -use infra_utils::commands::Command; -use infra_utils::paths::PathExtensions; - -use crate::toolchains::napi::glibc; -use crate::toolchains::napi::resolver::NapiResolver; - -pub enum BuildTarget { - Debug, - ReleaseTarget(String), -} - -pub struct NapiCliOutput { - /// `index.d.ts` and `index.js` - pub source_files: Vec, - /// `index.TARGET_NAME.node` - pub node_binary: PathBuf, -} - -pub struct NapiCli; - -impl NapiCli { - pub fn build( - resolver: NapiResolver, - output_dir: impl AsRef, - target: &BuildTarget, - ) -> Result { - let output_dir = output_dir.as_ref(); - let package_dir = resolver.main_package_dir(); - let crate_dir = resolver.rust_crate_dir(); - - let mut command = Command::new("napi"); - - { - // Note: NAPI expects all arguments to be relative to the current directory. - let output_dir = output_dir.strip_repo_root()?; - let package_dir = package_dir.strip_repo_root()?; - let crate_dir = crate_dir.strip_repo_root()?; - - command = command - .args(["build", output_dir.unwrap_str()]) - .property("--config", package_dir.join("package.json").unwrap_str()) - .property("--cargo-cwd", crate_dir.unwrap_str()); - } - - command = command - // Add platform triple to the binary file name. Example: "index.linux-x64-gnu.node" - .flag("--platform") - // Generate string enums, for serialization and debugging: - .flag("--no-const-enum"); - - match target { - BuildTarget::Debug => { - // Default - } - BuildTarget::ReleaseTarget(target) => { - command = command.flag("--release").property("--target", target); - } - }; - - command.run(); - - glibc::ensure_correct_glibc_for_vscode(resolver, output_dir, target)?; - - let mut source_files = vec![]; - let mut node_binary = None; - - for child in output_dir.collect_children()? { - let file_name = child.unwrap_name(); - - // NAPI emits files with lowercase names. - #[allow(clippy::case_sensitive_file_extension_comparisons)] - match file_name { - "index.js" | "index.d.ts" => { - source_files.push(output_dir.join(file_name)); - } - file if file.ends_with(".node") && node_binary.is_none() => { - node_binary = Some(output_dir.join(file)); - } - _ => { - bail!("Unexpected file {file_name:?} in {output_dir:?}"); - } - }; - } - - assert_eq!( - source_files.len(), - 2, - "Missing source files in {output_dir:?}", - ); - - let node_binary = - node_binary.with_context(|| format!("No .node file in {output_dir:?}"))?; - - Ok(NapiCliOutput { - source_files, - node_binary, - }) - } -} diff --git a/crates/infra/cli/src/toolchains/napi/compiler.rs b/crates/infra/cli/src/toolchains/napi/compiler.rs deleted file mode 100644 index 839aa017cb..0000000000 --- a/crates/infra/cli/src/toolchains/napi/compiler.rs +++ /dev/null @@ -1,180 +0,0 @@ -use std::path::{Path, PathBuf}; - -use anyhow::Result; -use infra_utils::cargo::CargoWorkspace; -use infra_utils::codegen::{CodegenFileSystem, TeraWrapper}; -use infra_utils::commands::Command; -use infra_utils::paths::PathExtensions; -use serde::Serialize; - -use crate::toolchains::napi::cli::{BuildTarget, NapiCli, NapiCliOutput}; -use crate::toolchains::napi::config::NapiConfig; -use crate::toolchains::napi::resolver::{NapiPackageKind, NapiResolver}; - -#[derive(Clone, Copy)] -pub enum NapiProfile { - /// Build only the main package for local development. - Debug, - /// Build all packages (all platforms) for publishing to NPM. - Release, -} - -pub struct NapiCompiler; - -impl NapiCompiler { - pub fn run(resolver: NapiResolver, profile: NapiProfile) -> Result<()> { - match profile { - NapiProfile::Debug => { - // Compiles the default target for local development - let napi_output = compile_target(resolver, &BuildTarget::Debug)?; - - // Process its generated JavaScript and TypeScript files, and copy any new changes to the source folder. - process_generated_files(resolver, &napi_output)?; - - // Compile the main cross-platform package, and copy the build node binary to it for debugging/testing. - compile_root_package(resolver, Some(&napi_output.node_binary))?; - } - NapiProfile::Release => { - // Compile all available targets for publishing to NPM. - let node_binaries = compile_all_targets(resolver)?; - - // Compile the main cross-platform package, but without any binaries. - compile_root_package(resolver, None)?; - - // Compile all platform-specific packages, and copy the built node binaries to them. - compile_platform_packages(resolver, &node_binaries)?; - } - } - - Ok(()) - } -} - -fn compile_all_targets(resolver: NapiResolver) -> Result> { - let targets = NapiConfig::list_all_targets(resolver)?; - - assert_ne!( - targets.len(), - 0, - "No release targets found. Is this a publicly released package?" - ); - - Command::new("rustup") - .args(["target", "add"]) - .args(&targets) - .run(); - - // Needed for cross-compiling windows targets: - CargoWorkspace::install_binary("cargo-xwin")?; - // Needed to reliably target older GBLIC on `-linux-gnu` targets when host-compiling: - CargoWorkspace::install_binary("cargo-zigbuild")?; - - let mut node_binaries = vec![]; - - for target in targets { - let output = compile_target(resolver, &BuildTarget::ReleaseTarget(target))?; - - node_binaries.push(output.node_binary); - } - - Ok(node_binaries) -} - -fn compile_target(resolver: NapiResolver, target: &BuildTarget) -> Result { - let output_dir = resolver.napi_output_dir(target); - - std::fs::create_dir_all(&output_dir)?; - - NapiCli::build(resolver, output_dir, target) -} - -#[derive(Serialize)] -struct LicenseHeaderModel { - contents: String, -} - -fn process_generated_files(resolver: NapiResolver, napi_output: &NapiCliOutput) -> Result<()> { - let templates_dir = - CargoWorkspace::locate_source_crate("infra_cli")?.join("src/toolchains/napi/bindings"); - - let tera = TeraWrapper::new(&templates_dir)?; - let mut fs = CodegenFileSystem::new(&templates_dir)?; - - for source in &napi_output.source_files { - let file_name = source.unwrap_name(); - let contents = source.read_to_string()?; - - let template_path = templates_dir.join(format!("{file_name}.jinja2")); - let destination_path = resolver.bindings_dir().join(file_name); - - let context = tera::Context::from_serialize(LicenseHeaderModel { contents })?; - let output = tera.render(&template_path, &context)?; - - fs.write_file(&destination_path, output)?; - } - - Ok(()) -} - -fn compile_root_package(resolver: NapiResolver, node_binary: Option<&Path>) -> Result<()> { - let package_dir = resolver.main_package_dir(); - let output_dir = resolver.npm_output_dir(&NapiPackageKind::Main); - - std::fs::create_dir_all(&output_dir)?; - - Command::new("tsc") - .property("--project", package_dir.join("tsconfig.json").unwrap_str()) - .property("--outDir", output_dir.unwrap_str()) - .property("--declaration", "true") - .property("--noEmit", "false") - .run(); - - for file_name in &["package.json", "CHANGELOG.md", "LICENSE", "README.md"] { - let source = package_dir.join(file_name); - let destination = output_dir.join(file_name); - - std::fs::copy(source, destination)?; - } - - let bindings_dir = resolver.bindings_dir(); - let bindings_output_dir = resolver.bindings_output_dir(); - - std::fs::create_dir_all(&bindings_output_dir)?; - - for child in bindings_dir.collect_children()? { - let destination = bindings_output_dir.join(child.unwrap_name()); - - std::fs::copy(child, destination)?; - } - - if let Some(node_binary) = node_binary { - let destination = bindings_output_dir.join(node_binary.unwrap_name()); - - std::fs::copy(node_binary, destination)?; - } - - Ok(()) -} - -fn compile_platform_packages(resolver: NapiResolver, node_binaries: &[PathBuf]) -> Result<()> { - for platform_dir in resolver.platforms_dir().collect_children()? { - let platform = platform_dir.unwrap_name(); - let package_kind = NapiPackageKind::Platform(platform.to_owned()); - let output_dir = resolver.npm_output_dir(&package_kind); - - std::fs::create_dir_all(&output_dir)?; - - for file in platform_dir.collect_children()? { - std::fs::copy(&file, output_dir.join(file.unwrap_name()))?; - } - - let node_binary = node_binaries - .iter() - .find(|node_binary| node_binary.unwrap_name() == format!("index.{platform}.node")) - .expect("Could not find node binary for platform."); - - std::fs::copy(node_binary, output_dir.join(node_binary.unwrap_name()))?; - } - - Ok(()) -} diff --git a/crates/infra/cli/src/toolchains/napi/config.rs b/crates/infra/cli/src/toolchains/napi/config.rs deleted file mode 100644 index e76ae581a2..0000000000 --- a/crates/infra/cli/src/toolchains/napi/config.rs +++ /dev/null @@ -1,90 +0,0 @@ -use std::path::Path; - -use anyhow::{Context, Result}; -use infra_utils::commands::Command; -use infra_utils::paths::PathExtensions; -use semver::Version; -use serde::Deserialize; - -use crate::toolchains::napi::glibc::ZigGlibcVersion; -use crate::toolchains::napi::resolver::NapiResolver; - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct Package { - name: String, - version: Version, - napi: Option, - slang_metadata: Option, -} - -#[derive(Deserialize)] -struct NapiEntry { - triples: NapiTriples, -} - -#[derive(Deserialize)] -struct NapiTriples { - defaults: bool, - additional: Vec, -} - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct SlangMetadata { - target_glibc: ZigGlibcVersion, -} - -pub struct NapiConfig; - -impl NapiConfig { - pub fn local_version(package_dir: impl AsRef) -> Result { - let package = load_package(package_dir.as_ref())?; - - Ok(package.version) - } - - pub fn published_version(package_dir: impl AsRef) -> Result { - let package = load_package(package_dir.as_ref())?; - - let version = Command::new("npm") - .args(["view", package.name.as_str(), "version"]) - .evaluate()?; - - Ok(Version::parse(version.trim())?) - } - - pub fn list_all_targets(resolver: NapiResolver) -> Result> { - let package = load_package(&resolver.main_package_dir())?; - - let triples = package - .napi - .context("Failed to find NAPI config section")? - .triples; - - assert!( - !triples.defaults, - "Package should explicitly list targets, instead of using defaults." - ); - - Ok(triples.additional) - } - - /// Returns the target glibc version for the GNU targets. - pub fn target_glibc(resolver: NapiResolver) -> Result { - let package = load_package(&resolver.main_package_dir())?; - - Ok(package - .slang_metadata - .context("Failed to find NAPI config metadata section")? - .target_glibc) - } -} - -fn load_package(package_dir: &Path) -> Result { - let package_json = package_dir.join("package.json").read_to_string()?; - - let package = serde_json::from_str::(&package_json)?; - - Ok(package) -} diff --git a/crates/infra/cli/src/toolchains/napi/glibc.rs b/crates/infra/cli/src/toolchains/napi/glibc.rs deleted file mode 100644 index e0da454a4f..0000000000 --- a/crates/infra/cli/src/toolchains/napi/glibc.rs +++ /dev/null @@ -1,219 +0,0 @@ -use std::path::Path; - -use anyhow::{bail, Result}; -use infra_utils::commands::Command; -use semver::Version; -use serde::de; - -use crate::toolchains::napi::{BuildTarget, NapiConfig, NapiResolver}; - -/// A GLIBC version (e.g. "2.16") supported by Zig(build) for cross-compilation. -/// -/// See the list of supported versions at . -#[derive(Clone, Copy, Debug)] -pub struct ZigGlibcVersion { - minor: u8, -} - -impl<'de> serde::Deserialize<'de> for ZigGlibcVersion { - fn deserialize>(deserializer: D) -> Result { - let value = String::deserialize(deserializer)?; - - let components: Vec<_> = value - .trim() - .split('.') - .map(|part| { - part.parse::() - .map_err(|_| de::Error::invalid_type(de::Unexpected::Str(part), &"u8")) - }) - .collect::>()?; - - match &components[..] { - [2, minor] if (16..=38).contains(minor) => Ok(ZigGlibcVersion { minor: *minor }), - _ => Err(de::Error::invalid_value( - de::Unexpected::Str(&value), - &"a valid Zig GLIBC version (2.16 - 2.38)", - )), - } - } -} - -impl std::fmt::Display for ZigGlibcVersion { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "2.{}", self.minor) - } -} - -impl From for Version { - fn from(version: ZigGlibcVersion) -> Self { - Version::new(2, u64::from(version.minor), 0) - } -} - -impl PartialOrd for ZigGlibcVersion { - fn partial_cmp(&self, other: &Version) -> Option { - Some(Version::from(*self).cmp(other)) - } -} - -impl PartialEq for ZigGlibcVersion { - fn eq(&self, other: &Version) -> bool { - Version::from(*self).eq(other) - } -} - -/// On a GNU host, cross-compile the native addon to only target the oldest supported GLIBC version by VS Code. -/// -/// By default, compiling on the host targets the host's GLIBC version, which is usually newer. -/// To prevent that, we need to explicitly cross-compile for the desired GLIBC version. -/// -/// This is necessary to retain extension compatibility with as many systems as possible: -/// . -pub fn ensure_correct_glibc_for_vscode( - resolver: NapiResolver, - output_dir: &Path, - target: &BuildTarget, -) -> Result<()> { - // This is only ever required when host-compiling on a GNU system. - if cfg!(not(target_env = "gnu")) { - return Ok(()); - } - - let target_triple = match target { - BuildTarget::ReleaseTarget(target) if target.ends_with("-linux-gnu") => target, - _ => return Ok(()), - }; - - let target_glibc = NapiConfig::target_glibc(resolver)?; - - let output_artifact = match target_triple.split('-').next() { - Some("x86_64") => "index.linux-x64-gnu.node", - Some("aarch64") => "index.linux-arm64-gnu.node", - _ => bail!("Unsupported target {target_triple} for `cargo-zigbuild`."), - }; - let output_artifact_path = output_dir.join(output_artifact); - - let is_host_compiling = target_triple.starts_with(std::env::consts::ARCH); - if is_host_compiling { - let rust_crate_name = resolver.rust_crate_name(); - - // Don't clobber the existing output directory. - let zigbuild_output = tempfile::tempdir()?; - - // Until `@napi-rs/cli` v3 is released with a fixed `zig` support and a new `--cross-compile`, - // we explicitly compile ourselves again with `cargo-zigbuild` to target the desired GLIBC - // version, without having to separately compile on the target platform (e.g. via Docker). - Command::new("cargo") - .arg("zigbuild") - .property("-p", rust_crate_name) - .flag("--release") - .property("--target", format!("{target_triple}.{target_glibc}")) - .property("--target-dir", zigbuild_output.path().to_string_lossy()) - .run(); - - // Overwrite the existing artifact with the cross-compiled one. - let zigbuild_output = zigbuild_output.into_path(); - let artifact_path = zigbuild_output - .join(target_triple) - .join("release") - .join(format!("lib{rust_crate_name}.so")); - - std::fs::copy(artifact_path, &output_artifact_path)?; - } else { - // Already cross-compiled with the correct GLIBC version. Just verify for sanity. - } - - // Verify that the artifact is compatible with the desired GLIBC version. - let library_glibc_version = - fetch_min_supported_glibc_version(&output_artifact_path.to_string_lossy())?; - - if target_glibc < library_glibc_version { - bail!("The compiled artifact {output_artifact_path:?} targets GLIBC {library_glibc_version}, which is higher than the minimum specified version {target_glibc}."); - } - - Ok(()) -} - -fn fetch_min_supported_glibc_version(lib_path: &str) -> Result { - assert!( - cfg!(target_env = "gnu"), - "This is only supported and expected to only ever run on a host GNU system." - ); - - // # Note: `ldd` does not work reliably when inspecting cross-compiled ARM binaries on x86_64 - let output = Command::new("objdump") - .flag("-T") - .arg(lib_path) - .evaluate()?; - - Ok(extract_min_supported_glibc_from_objdump(&output)) -} - -fn extract_min_supported_glibc_from_objdump(objdump_output: &str) -> Version { - // Find and capture "2.3.5" (3rd component optional) from "(GLIBC_2.3.5)" substrings - let regexp = - regex::Regex::new(r"\(GLIBC_(?[0-9])+\.(?[0-9]+)(.(?[0-9]+))?.*\)") - .unwrap(); - regexp - .captures_iter(objdump_output) - .map(|capture| { - let major = capture.name("major").unwrap().as_str(); - let minor = capture.name("minor").unwrap().as_str(); - let patch = capture.name("patch").map_or("0", |x| x.as_str()); - let [major, minor, patch] = [major, minor, patch].map(|x| x.parse::().unwrap()); - - semver::Version::new(major, minor, patch) - }) - .max() - .expect("at least one version to be matched") -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_extract_min_supported_glibc_from_objdump() { - const OUTPUT: &str = r" - crates/solidity/outputs/npm/package/target/napi/x86_64-unknown-linux-gnu/index.linux-x64-gnu.node: file format elf64-x86-64 - - DYNAMIC SYMBOL TABLE: - 0000000000000000 w D *UND* 0000000000000000 Base __gmon_start__ - 0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.3) __tls_get_addr - 0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) free - 0000000000000000 D *UND* 0000000000000000 Base napi_delete_reference - 0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.14) memcpy - 0000000000000000 DF *UND* 0000000000000000 (GLIBC_2.2.5) malloc - "; - - let result = extract_min_supported_glibc_from_objdump(OUTPUT); - assert_eq!(result, Version::new(2, 14, 0)); - } - - #[test] - fn test_deserialize_zig_glibc_version() -> Result<()> { - let version = serde_json::from_str::(r#""2.16""#)?; - assert_eq!(version.minor, 16); - - let version = serde_json::from_str::(r#""2.38""#)?; - assert_eq!(version.minor, 38); - - let version = serde_json::from_str::(r#""2.39""#); - assert!(version.is_err()); - - let version = serde_json::from_str::(r#""3.20""#); - assert!(version.is_err()); - - // Zig only supports versions without the patch component. - let version = serde_json::from_str::(r#""2.2.5""#); - assert!(version.is_err()); - - Ok(()) - } - - #[test] - fn test_display() { - let version = ZigGlibcVersion { minor: 16 }; - assert_eq!(format!("{version}"), "2.16"); - } -} diff --git a/crates/infra/cli/src/toolchains/napi/mod.rs b/crates/infra/cli/src/toolchains/napi/mod.rs deleted file mode 100644 index f5197f0407..0000000000 --- a/crates/infra/cli/src/toolchains/napi/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -mod cli; -mod compiler; -mod config; -mod glibc; -mod resolver; - -pub use cli::*; -pub use compiler::*; -pub use config::*; -pub use resolver::*; diff --git a/crates/infra/cli/src/toolchains/napi/resolver.rs b/crates/infra/cli/src/toolchains/napi/resolver.rs deleted file mode 100644 index c29805b44c..0000000000 --- a/crates/infra/cli/src/toolchains/napi/resolver.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::path::PathBuf; - -use infra_utils::cargo::CargoWorkspace; -use strum_macros::EnumIter; - -use crate::toolchains::napi::cli::BuildTarget; - -pub enum NapiPackageKind { - Main, - Platform(String), -} - -#[derive(Clone, Copy, EnumIter)] -pub enum NapiResolver { - Codegen, - Solidity, - Testlang, -} - -impl NapiResolver { - pub fn rust_crate_name(self) -> &'static str { - match self { - Self::Codegen => "codegen_runtime_node_addon", - Self::Solidity => "slang_solidity_node_addon", - Self::Testlang => "slang_testlang_node_addon", - } - } - - pub fn main_package_name(self) -> &'static str { - match self { - Self::Codegen => "codegen_runtime_npm", - Self::Solidity => "solidity_npm_package", - Self::Testlang => "testlang_npm_package", - } - } - - pub fn rust_crate_dir(self) -> PathBuf { - CargoWorkspace::locate_source_crate(self.rust_crate_name()).unwrap() - } - - pub fn main_package_dir(self) -> PathBuf { - CargoWorkspace::locate_source_crate(self.main_package_name()).unwrap() - } - - pub fn platforms_dir(self) -> PathBuf { - self.main_package_dir().join("platforms") - } - - pub fn bindings_dir(self) -> PathBuf { - self.main_package_dir().join(match self { - // Source templates: - Self::Codegen => "src/runtime/napi-bindings/generated", - // Generated Languages: - Self::Solidity | Self::Testlang => "src/generated/napi-bindings/generated", - }) - } - - pub fn bindings_output_dir(self) -> PathBuf { - self.npm_output_dir(&NapiPackageKind::Main) - .join("napi-bindings/generated") - } - - pub fn napi_output_dir(self, target: &BuildTarget) -> PathBuf { - self.main_package_dir() - .join("target/napi") - .join(match target { - BuildTarget::Debug => "debug", - BuildTarget::ReleaseTarget(target) => target, - }) - } - - pub fn npm_output_dir(self, kind: &NapiPackageKind) -> PathBuf { - self.main_package_dir().join("target/npm").join(match kind { - NapiPackageKind::Main => { - // __SLANG_NPM_PACKAGE_MAIN_OUTPUT_DIR__ (keep in sync) - "main" - } - NapiPackageKind::Platform(platform) => platform, - }) - } -} diff --git a/crates/infra/cli/src/toolchains/npm/mod.rs b/crates/infra/cli/src/toolchains/npm/mod.rs new file mode 100644 index 0000000000..9afe6d2e9b --- /dev/null +++ b/crates/infra/cli/src/toolchains/npm/mod.rs @@ -0,0 +1,42 @@ +use std::path::Path; + +use anyhow::Result; +use infra_utils::commands::Command; +use infra_utils::paths::PathExtensions; +use semver::Version; +use serde::Deserialize; + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase")] +struct Package { + name: String, + version: Version, +} + +pub struct Npm; + +impl Npm { + pub fn local_version(package_dir: impl AsRef) -> Result { + let package = load_package(package_dir.as_ref())?; + + Ok(package.version) + } + + pub fn published_version(package_dir: impl AsRef) -> Result { + let package = load_package(package_dir.as_ref())?; + + let version = Command::new("npm") + .args(["view", package.name.as_str(), "version"]) + .evaluate()?; + + Ok(Version::parse(version.trim())?) + } +} + +fn load_package(package_dir: &Path) -> Result { + let package_json = package_dir.join("package.json").read_to_string()?; + + let package = serde_json::from_str::(&package_json)?; + + Ok(package) +} diff --git a/crates/infra/cli/src/toolchains/wasm/mod.rs b/crates/infra/cli/src/toolchains/wasm/mod.rs new file mode 100644 index 0000000000..160c5231ab --- /dev/null +++ b/crates/infra/cli/src/toolchains/wasm/mod.rs @@ -0,0 +1,190 @@ +use std::path::{Path, PathBuf}; + +use anyhow::Result; +use infra_utils::cargo::{CargoWorkspace, CargoWorkspaceCommands}; +use infra_utils::codegen::CodegenFileSystem; +use infra_utils::commands::Command; +use infra_utils::paths::{FileWalker, PathExtensions}; +use strum_macros::EnumIter; + +pub const WASM_TARGET: &str = "wasm32-wasi"; + +#[derive(Clone, Copy, EnumIter)] +pub enum WasmPackage { + Codegen, + Solidity, + Testlang, +} + +impl WasmPackage { + pub fn build(self) -> Result<()> { + let wasm_component = self.generate_component()?; + + self.transpile_wasm(&wasm_component)?; + + self.transpile_sources()?; + + Ok(()) + } + + fn generate_component(self) -> Result { + let wasm_crate = self.wasm_crate(); + + Command::new("cargo") + .arg("build") + .property("--target", WASM_TARGET) + .property("--package", wasm_crate) + .flag("--all-features") + .flag("--release") + .add_build_rustflags() + .run(); + + let wasm_binary = + Path::repo_path(format!("target/{WASM_TARGET}/release/{wasm_crate}.wasm")); + + let wasm_opt_binary = Path::repo_path(format!( + "target/{WASM_TARGET}/release/{wasm_crate}.optimized.wasm" + )); + + Command::new("node") + .args(["submodules/jco/src/jco.js", "opt", wasm_binary.unwrap_str()]) + .property("--output", wasm_opt_binary.unwrap_str()) + .arg("--") + .property("--optimize-level", "4") + .flag("--strip-debug") + .run(); + + CargoWorkspace::install_binary("wasm-tools")?; + + let wasm_adapter = + Path::repo_path("submodules/jco/lib/wasi_snapshot_preview1.reactor.wasm"); + + let wasm_component = Path::repo_path(format!( + "target/{WASM_TARGET}/release/{wasm_crate}.component.wasm" + )); + + Command::new("wasm-tools") + .args(["component", "new", wasm_opt_binary.unwrap_str()]) + .property("--adapt", wasm_adapter.unwrap_str()) + .property("--output", wasm_component.unwrap_str()) + .run(); + + Ok(wasm_component) + } + + fn transpile_wasm(self, wasm_component: &Path) -> Result<()> { + let temp_dir_handle = tempfile::tempdir()?; + let temp_dir = temp_dir_handle.path(); + + { + let wasm_crate = self.wasm_crate(); + let jco_config = CargoWorkspace::locate_source_crate(wasm_crate)? + .join(self.runtime_dir()) + .join("generated/config.json"); + + Command::new("node") + .args([ + "submodules/jco/src/jco.js", + "transpile", + wasm_component.unwrap_str(), + ]) + .property("--configuration-file", jco_config.unwrap_str()) + .property("--out-dir", temp_dir.unwrap_str()) + .property("--base64-cutoff", "0") // disable inlining core Wasm binaries as base64 + .flag("--no-namespaced-exports") // disable namespaced exports for typescript compatibility + .flag("--valid-lifting-optimization") // optimize component binary validations assuming all lifted values are valid + .run(); + } + + let npm_crate = self.npm_crate(); + let output_dir = CargoWorkspace::locate_source_crate(npm_crate)?.join("wasm/generated"); + + let mut fs = CodegenFileSystem::new(&output_dir)?; + + for temp_path in FileWalker::from_directory(temp_dir).find_all()? { + let output_path = temp_path.replace_prefix(temp_dir, &output_dir); + + match temp_path.unwrap_ext() { + "ts" => { + // Copy definition files as-is: + let contents = temp_path.read_to_string()?; + fs.write_file(output_path, contents)?; + } + + "js" => { + // Disable type checking for JS, since we have no control over the generated output: + let mut contents = temp_path.read_to_string()?; + contents.insert_str(0, "// @ts-nocheck\n\n"); + + // Files git-ignored. Don't go through our codegen/formatting APIs: + std::fs::write(&output_path, contents)?; + fs.mark_generated_file(output_path)?; + } + + "wasm" => { + // Files git-ignored. Don't go through our codegen/formatting APIs: + std::fs::copy(&temp_path, &output_path)?; + fs.mark_generated_file(output_path)?; + } + + other => panic!("Unexpected file extension: {other}"), + } + } + + Ok(()) + } + + fn transpile_sources(self) -> Result<()> { + let npm_crate = self.npm_crate(); + let project_dir = CargoWorkspace::locate_source_crate(npm_crate)?; + + let temp_dir_handle = tempfile::tempdir()?; + let temp_dir = temp_dir_handle.path(); + + Command::new("tsc") + .property("--project", project_dir.join("tsconfig.json").unwrap_str()) + .property("--outDir", temp_dir.unwrap_str()) + .property("--noEmit", "false") + .run(); + + let temp_dir = temp_dir.join(self.runtime_dir()); + let output_dir = project_dir.join("target/generated"); + + // remove any old generated files + if output_dir.exists() { + std::fs::remove_dir_all(&output_dir)?; + } + + for temp_path in FileWalker::from_directory(&temp_dir).find_all()? { + let output_path = temp_path.replace_prefix(&temp_dir, &output_dir); + + std::fs::create_dir_all(output_path.unwrap_parent())?; + std::fs::copy(&temp_path, &output_path)?; + } + + Ok(()) + } + + pub fn wasm_crate(self) -> &'static str { + match self { + Self::Codegen => "codegen_runtime_cargo_wasm", + Self::Solidity => "solidity_cargo_wasm", + Self::Testlang => "testlang_cargo_wasm", + } + } + + pub fn npm_crate(self) -> &'static str { + match self { + Self::Codegen => "codegen_runtime_npm_package", + Self::Solidity => "solidity_npm_package", + Self::Testlang => "testlang_npm_package", + } + } + + fn runtime_dir(self) -> &'static str { + match self { + Self::Codegen => "src/runtime", + Self::Solidity | Self::Testlang => "src/generated", + } + } +} diff --git a/crates/infra/utils/src/codegen/formatting.rs b/crates/infra/utils/src/codegen/formatting.rs index d9b10f8cc8..8c9546ae37 100644 --- a/crates/infra/utils/src/codegen/formatting.rs +++ b/crates/infra/utils/src/codegen/formatting.rs @@ -24,43 +24,37 @@ fn generate_header(file_path: &Path) -> String { let warning_line = "This file is generated automatically by infrastructure scripts. Please don't edit by hand."; - return match get_extension(file_path) { - "ebnf" => format!("(* {warning_line} *)"), - "json" => String::new(), - "html" | "md" => format!(""), - "dot" | "js" | "rs" | "ts" | "wit" => format!("// {warning_line}"), - "yml" | "txt" => format!("# {warning_line}"), - "mmd" => format!("%% {warning_line}"), - ext => panic!("Unsupported extension to generate a header for: {ext}"), - }; -} + match (file_path.unwrap_name(), file_path.unwrap_ext()) { + // Known names: + (".gitignore", _) => format!("# {warning_line}"), + + // Known extensions: + (_, "ebnf") => format!("(* {warning_line} *)"), + (_, "json") => String::new(), + (_, "html" | "md") => format!(""), + (_, "dot" | "js" | "mts" | "rs" | "ts" | "wit") => format!("// {warning_line}"), + (_, "yml" | "txt") => format!("# {warning_line}"), + (_, "mmd") => format!("%% {warning_line}"), -fn get_extension(file_path: &Path) -> &str { - return file_path - .extension() - .with_context(|| format!("Cannot get extension of file: {file_path:?}")) - .unwrap() - .to_str() - .with_context(|| format!("Cannot read extension of file: {file_path:?}")) - .unwrap(); + _ => panic!("Unsupported path to generate a header for: {file_path:?}"), + } } fn run_formatter(file_path: &Path, contents: &str) -> Result { - return match get_extension(file_path) { - "js" | "json" | "ts" => run_prettier(file_path, contents), - "rs" => run_rustfmt(contents), - "html" | "md" | "yml" => { - // We already generate formatted content for these, so no need to run expensive formatting. - Ok(contents.to_owned()) - } - "dot" | "ebnf" | "mmd" | "txt" | "wit" => { - // No formatters available for these (yet). - Ok(contents.to_owned()) - } - ext => { - panic!("Unsupported extension to format: {ext}"); - } - }; + match (file_path.unwrap_name(), file_path.unwrap_ext()) { + // We have formatters available for these: + (_, "js" | "json" | "mts" | "ts") => run_prettier(file_path, contents), + (_, "rs") => run_rustfmt(contents), + + // No formatters available for these yet: + (".gitignore", _) => Ok(contents.to_owned()), + (_, "dot" | "ebnf" | "mmd" | "txt" | "wit") => Ok(contents.to_owned()), + + // We already generate formatted content for these, so no need to run expensive formatting: + (_, "html" | "md" | "yml") => Ok(contents.to_owned()), + + _ => panic!("Unsupported path to format: {file_path:?}"), + } } fn run_prettier(file_path: &Path, contents: &str) -> Result { diff --git a/crates/infra/utils/src/codegen/runtime.rs b/crates/infra/utils/src/codegen/runtime.rs index 9083e7fe99..533593cef7 100644 --- a/crates/infra/utils/src/codegen/runtime.rs +++ b/crates/infra/utils/src/codegen/runtime.rs @@ -40,7 +40,7 @@ impl CodegenRuntime { Ok(()) } - pub fn render_directory( + pub fn render_product( &mut self, model: impl Serialize, output_dir: impl AsRef, @@ -52,7 +52,7 @@ impl CodegenRuntime { for template_path in self.tera.find_all_templates()? { let stub_path = Self::get_stub_path(&template_path).with_extension(""); - let rendered_path = self.get_output_path(&stub_path, output_dir)?; + let rendered_path = stub_path.replace_prefix(&self.input_dir, output_dir); let rendered = self.tera.render(&template_path, &context)?; self.fs.write_file(&rendered_path, rendered)?; @@ -65,7 +65,7 @@ impl CodegenRuntime { .find_all()? .filter(|source_path| !handled.contains(source_path)) { - let output_path = self.get_output_path(&source_path, output_dir)?; + let output_path = source_path.replace_prefix(&self.input_dir, output_dir); // Preserve the source of otherwise-generated files: if source_path.generated_dir().is_ok() { @@ -86,8 +86,4 @@ impl CodegenRuntime { .join("generated") .join(base_name) } - - fn get_output_path(&self, source_path: &Path, output_dir: &Path) -> Result { - Ok(output_dir.join(source_path.strip_prefix(&self.input_dir)?)) - } } diff --git a/crates/infra/utils/src/paths/extensions.rs b/crates/infra/utils/src/paths/extensions.rs index 7d81ab60d6..313fa984eb 100644 --- a/crates/infra/utils/src/paths/extensions.rs +++ b/crates/infra/utils/src/paths/extensions.rs @@ -13,6 +13,9 @@ pub trait PathExtensions { fn strip_repo_root(&self) -> Result<&Path>; + fn replace_prefix(&self, old_prefix: impl AsRef, new_prefix: impl AsRef) + -> PathBuf; + fn unwrap_str(&self) -> &str; fn unwrap_string(&self) -> String; @@ -21,6 +24,8 @@ pub trait PathExtensions { fn unwrap_parent(&self) -> &Path; + fn unwrap_ext(&self) -> &str; + fn read_to_string(&self) -> Result; fn write_string(&self, contents: impl AsRef) -> Result<()>; @@ -70,6 +75,22 @@ impl PathExtensions for Path { .with_context(|| format!("Failed to strip repo root from: {self:?}")); } + fn replace_prefix( + &self, + old_prefix: impl AsRef, + new_prefix: impl AsRef, + ) -> PathBuf { + let old_prefix = old_prefix.as_ref(); + let new_prefix = new_prefix.as_ref(); + + let suffix = self + .strip_prefix(old_prefix) + .with_context(|| format!("Failed to strip prefix: {old_prefix:?} from: {self:?}")) + .unwrap(); + + new_prefix.join(suffix) + } + fn unwrap_str(&self) -> &str { return self .to_str() @@ -98,6 +119,15 @@ impl PathExtensions for Path { .unwrap(); } + fn unwrap_ext(&self) -> &str { + return self + .extension() + .unwrap_or_default() + .to_str() + .with_context(|| format!("Failed to convert extension to str: {self:?}")) + .unwrap(); + } + fn read_to_string(&self) -> Result { std::fs::read_to_string(self).with_context(|| format!("Failed to read file: {self:?}")) } diff --git a/crates/infra/utils/src/paths/walker.rs b/crates/infra/utils/src/paths/walker.rs index 6b06e753cd..5ab82e0431 100644 --- a/crates/infra/utils/src/paths/walker.rs +++ b/crates/infra/utils/src/paths/walker.rs @@ -38,6 +38,10 @@ impl FileWalker { // Since we allow hidden (dot) files below, we need to explicitly ignore the .git directory: builder.add("!.git/")?; + // Skip git submodules used in this repository: + builder.add("!submodules/")?; + + // Add user-provided globs: for glob in globs { builder.add(glob.as_ref())?; } diff --git a/crates/infra/utils/src/terminal/mod.rs b/crates/infra/utils/src/terminal/mod.rs index d2d09f65e3..a3dd8cbfce 100644 --- a/crates/infra/utils/src/terminal/mod.rs +++ b/crates/infra/utils/src/terminal/mod.rs @@ -5,7 +5,7 @@ use num_format::ToFormattedString; pub struct Terminal; impl Terminal { - pub fn wrap_execution(operation: impl FnOnce() -> Result<()>) { + pub fn wrap_execution(operation: impl FnOnce() -> Result<()>) -> Result<()> { let std_hook = std::panic::take_hook(); std::panic::set_hook(Box::new(move |info| { @@ -17,8 +17,11 @@ impl Terminal { Self::banner(Color::Red, "Failure"); })); - operation().unwrap(); + operation()?; + Self::banner(Color::Green, "Success"); + + Ok(()) } pub fn step(message: impl Into) { diff --git a/crates/metaslang/bindings/Cargo.toml b/crates/metaslang/bindings/Cargo.toml index 023992704a..e70a944678 100644 --- a/crates/metaslang/bindings/Cargo.toml +++ b/crates/metaslang/bindings/Cargo.toml @@ -31,6 +31,7 @@ thiserror = { workspace = true } [dev-dependencies] [features] +default = [] __private_testing_utils = [] [lints] diff --git a/crates/metaslang/cst/generated/public_api.txt b/crates/metaslang/cst/generated/public_api.txt index 5335c4a712..3f00927431 100644 --- a/crates/metaslang/cst/generated/public_api.txt +++ b/crates/metaslang/cst/generated/public_api.txt @@ -104,7 +104,7 @@ pub fn metaslang_cst::nodes::Node::labeled_edges(&self) -> impl core::iter::t pub fn metaslang_cst::nodes::Node::nonterminal(kind: ::NonterminalKind, children: alloc::vec::Vec>) -> Self pub fn metaslang_cst::nodes::Node::terminal(kind: ::TerminalKind, text: alloc::string::String) -> Self pub fn metaslang_cst::nodes::Node::text_len(&self) -> metaslang_cst::text_index::TextIndex -pub fn metaslang_cst::nodes::Node::unparse(self) -> alloc::string::String +pub fn metaslang_cst::nodes::Node::unparse(&self) -> alloc::string::String impl core::clone::Clone for metaslang_cst::nodes::Node pub fn metaslang_cst::nodes::Node::clone(&self) -> metaslang_cst::nodes::Node impl core::cmp::Eq for metaslang_cst::nodes::Node @@ -159,7 +159,8 @@ pub metaslang_cst::nodes::NonterminalNode::kind: metaslang_cst::nodes::NonterminalNode pub fn metaslang_cst::nodes::NonterminalNode::cursor_with_offset(self: alloc::rc::Rc, text_offset: metaslang_cst::text_index::TextIndex) -> metaslang_cst::cursor::Cursor -pub fn metaslang_cst::nodes::NonterminalNode::unparse(self: alloc::rc::Rc) -> alloc::string::String +pub fn metaslang_cst::nodes::NonterminalNode::id(self: &alloc::rc::Rc) -> usize +pub fn metaslang_cst::nodes::NonterminalNode::unparse(&self) -> alloc::string::String impl core::clone::Clone for metaslang_cst::nodes::NonterminalNode where ::NonterminalKind: core::clone::Clone pub fn metaslang_cst::nodes::NonterminalNode::clone(&self) -> metaslang_cst::nodes::NonterminalNode impl core::cmp::Eq for metaslang_cst::nodes::NonterminalNode where ::NonterminalKind: core::cmp::Eq @@ -173,6 +174,9 @@ pub fn metaslang_cst::nodes::NonterminalNode::serialize<__S>(&self, __seriali pub struct metaslang_cst::nodes::TerminalNode pub metaslang_cst::nodes::TerminalNode::kind: ::TerminalKind pub metaslang_cst::nodes::TerminalNode::text: alloc::string::String +impl metaslang_cst::nodes::TerminalNode +pub fn metaslang_cst::nodes::TerminalNode::id(self: &alloc::rc::Rc) -> usize +pub fn metaslang_cst::nodes::TerminalNode::unparse(&self) -> alloc::string::String impl core::clone::Clone for metaslang_cst::nodes::TerminalNode where ::TerminalKind: core::clone::Clone pub fn metaslang_cst::nodes::TerminalNode::clone(&self) -> metaslang_cst::nodes::TerminalNode impl core::cmp::Eq for metaslang_cst::nodes::TerminalNode where ::TerminalKind: core::cmp::Eq @@ -211,8 +215,8 @@ impl core::fmt::Display for metaslang_cst::q pub fn metaslang_cst::query::Query::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub struct metaslang_cst::query::QueryError pub metaslang_cst::query::QueryError::column: usize +pub metaslang_cst::query::QueryError::line: usize pub metaslang_cst::query::QueryError::message: alloc::string::String -pub metaslang_cst::query::QueryError::row: usize impl core::clone::Clone for metaslang_cst::query::QueryError pub fn metaslang_cst::query::QueryError::clone(&self) -> metaslang_cst::query::QueryError impl core::error::Error for metaslang_cst::query::QueryError diff --git a/crates/metaslang/cst/src/nodes.rs b/crates/metaslang/cst/src/nodes.rs index e6c93012f5..0e96219ee8 100644 --- a/crates/metaslang/cst/src/nodes.rs +++ b/crates/metaslang/cst/src/nodes.rs @@ -43,12 +43,16 @@ pub struct TerminalNode { #[derive(Clone, Debug, PartialEq, Eq, Serialize)] pub struct NonterminalNode { pub kind: T::NonterminalKind, + + // skip serde since this doesn't exist on `TerminalNode`. We can add to both in the future if found useful. + #[serde(skip)] pub text_len: TextIndex, - #[serde(skip_serializing_if = "Vec::is_empty")] + pub children: Vec>, } #[derive(Clone, Debug, PartialEq, Eq, Serialize)] +#[serde(untagged)] pub enum Node { Nonterminal(Rc>), Terminal(Rc>), @@ -94,8 +98,8 @@ impl Node { /// and cannot be used in a persistent/serialised sense. pub fn id(&self) -> usize { match self { - Self::Nonterminal(node) => Rc::as_ptr(node) as usize, - Self::Terminal(node) => Rc::as_ptr(node) as usize, + Self::Nonterminal(node) => node.id(), + Self::Terminal(node) => node.id(), } } @@ -135,11 +139,11 @@ impl Node { Cursor::new(self.clone(), text_offset) } - /// Reconstructs the original source code from the parse tree. - pub fn unparse(self) -> String { + /// Reconstructs the original source code from the node and its sub-tree. + pub fn unparse(&self) -> String { match self { - Self::Nonterminal(nonterminal) => nonterminal.unparse(), - Self::Terminal(terminal) => terminal.text.clone(), + Self::Nonterminal(node) => node.unparse(), + Self::Terminal(node) => node.unparse(), } } @@ -243,20 +247,43 @@ impl From>> for Node { } impl NonterminalNode { + /// Returns a unique identifier of the node. It is not reproducable over parses + /// and cannot be used in a persistent/serialised sense. + pub fn id(self: &Rc) -> usize { + Rc::as_ptr(self) as usize + } + /// Creates a [`Cursor`] that starts at the current node as the root and a given initial `text_offset`. pub fn cursor_with_offset(self: Rc, text_offset: TextIndex) -> Cursor { Cursor::new(Node::Nonterminal(self), text_offset) } - /// Reconstructs the original source code from the parse tree. - pub fn unparse(self: Rc) -> String { - let acc = String::with_capacity(self.text_len.utf8); + /// Reconstructs the original source code from the node and its sub-tree. + pub fn unparse(&self) -> String { + fn aux(parent: &NonterminalNode, buffer: &mut String) { + for child in &parent.children { + match &child.node { + Node::Nonterminal(node) => aux(node, buffer), + Node::Terminal(node) => buffer.push_str(&node.text), + }; + } + } + + let mut buffer = String::with_capacity(self.text_len.utf8); + aux(self, &mut buffer); + buffer + } +} + +impl TerminalNode { + /// Returns a unique identifier of the node. It is not reproducable over parses + /// and cannot be used in a persistent/serialised sense. + pub fn id(self: &Rc) -> usize { + Rc::as_ptr(self) as usize + } - self.cursor_with_offset(TextIndex::ZERO) - .filter_map(|node| node.into_terminal()) - .fold(acc, |mut acc, terminal| { - acc.push_str(&terminal.text); - acc - }) + /// Reconstructs the original source code from the node and its sub-tree. + pub fn unparse(&self) -> String { + self.text.clone() } } diff --git a/crates/metaslang/cst/src/query/model.rs b/crates/metaslang/cst/src/query/model.rs index aa7357087a..87da193653 100644 --- a/crates/metaslang/cst/src/query/model.rs +++ b/crates/metaslang/cst/src/query/model.rs @@ -25,7 +25,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, }); } @@ -70,7 +70,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 0d5cf235a3..300e985f48 100644 --- a/crates/metaslang/cst/src/query/parser.rs +++ b/crates/metaslang/cst/src/query/parser.rs @@ -27,7 +27,7 @@ use crate::text_index::TextIndex; #[derive(Clone, Debug, Error)] pub struct QueryError { pub message: String, - pub row: usize, + pub line: usize, pub column: usize, } @@ -133,7 +133,7 @@ pub(super) fn parse_query(input: &str) -> Result, Query let text_index = compute_row_and_column(e.errors[0].0, input); QueryError { message: e.to_string(), - row: text_index.line, + line: text_index.line, column: text_index.column, } }) diff --git a/crates/metaslang/graph_builder/src/parser.rs b/crates/metaslang/graph_builder/src/parser.rs index fd0ed12d0f..85c4a87a82 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, @@ -372,11 +372,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 782a8e4b55..a8c4c3cf28 100644 --- a/crates/metaslang/graph_builder/tests/parser.rs +++ b/crates/metaslang/graph_builder/tests/parser.rs @@ -1584,7 +1584,7 @@ fn query_parse_errors_have_file_location() { Err(e) => panic!("Unexpected error: {e}"), }; assert_eq!(err.message, "Parse error:\n'NonExistingNode' is not a valid node kind at: NonExistingNode ] ]\n \n"); - 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, 19, "expected column 19, got {}", err.column); // assert_eq!(err.offset, 48, "expected offset 48, got {}", err.offset); } @@ -1606,7 +1606,7 @@ fn multiline_query_parse_errors_have_file_location() { Err(e) => panic!("Unexpected error: {e}"), }; assert_eq!(err.message, "Parse error:\n'NonExistingNode' is not a valid node kind at: NonExistingNode ] ]\n )\n \n"); - assert_eq!(err.row, 5, "expected row 5, got {}", err.row); + assert_eq!(err.line, 5, "expected row 5, got {}", err.line); assert_eq!(err.column, 23, "expected column 23, got {}", err.column); // assert_eq!(err.offset, 112, "expected offset 112, got {}", err.offset); } diff --git a/crates/solidity/inputs/language/src/definition.rs b/crates/solidity/inputs/language/src/definition.rs index b5a8b44c8d..63fe686098 100644 --- a/crates/solidity/inputs/language/src/definition.rs +++ b/crates/solidity/inputs/language/src/definition.rs @@ -93,13 +93,13 @@ codegen_language_macros::compile!(Language( Enum( name = Pragma, variants = [ - EnumVariant(reference = ABICoderPragma), + EnumVariant(reference = AbicoderPragma), EnumVariant(reference = ExperimentalPragma), EnumVariant(reference = VersionPragma) ] ), Struct( - name = ABICoderPragma, + name = AbicoderPragma, fields = ( abicoder_keyword = Required(AbicoderKeyword), version = Required(Identifier) diff --git a/crates/solidity/outputs/cargo/slang_solidity/CHANGELOG.md b/crates/solidity/outputs/cargo/cli/CHANGELOG.md similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/CHANGELOG.md rename to crates/solidity/outputs/cargo/cli/CHANGELOG.md diff --git a/crates/solidity/outputs/cargo/slang_solidity_cli/Cargo.toml b/crates/solidity/outputs/cargo/cli/Cargo.toml similarity index 83% rename from crates/solidity/outputs/cargo/slang_solidity_cli/Cargo.toml rename to crates/solidity/outputs/cargo/cli/Cargo.toml index 33ab77e6db..b3249b251b 100644 --- a/crates/solidity/outputs/cargo/slang_solidity_cli/Cargo.toml +++ b/crates/solidity/outputs/cargo/cli/Cargo.toml @@ -31,7 +31,10 @@ name = "slang_solidity" path = "src/main.rs" [dependencies] -slang_solidity = { workspace = true, features = ["__private_cli_execution"] } +clap = { workspace = true } +serde_json = { workspace = true } +semver = { workspace = true } +slang_solidity = { workspace = true, features = ["__private_ariadne_errors"] } [lints] workspace = true diff --git a/crates/solidity/outputs/cargo/slang_solidity/LICENSE b/crates/solidity/outputs/cargo/cli/LICENSE similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/LICENSE rename to crates/solidity/outputs/cargo/cli/LICENSE diff --git a/crates/solidity/outputs/cargo/slang_solidity_cli/README.md b/crates/solidity/outputs/cargo/cli/README.md similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity_cli/README.md rename to crates/solidity/outputs/cargo/cli/README.md diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs b/crates/solidity/outputs/cargo/cli/src/main.rs similarity index 88% rename from crates/codegen/runtime/cargo/src/runtime/cli/mod.rs rename to crates/solidity/outputs/cargo/cli/src/main.rs index e084a76484..93bc8b0326 100644 --- a/crates/codegen/runtime/cargo/src/runtime/cli/mod.rs +++ b/crates/solidity/outputs/cargo/cli/src/main.rs @@ -1,8 +1,8 @@ -mod commands; +mod parse; use clap::{Parser, Subcommand}; -use crate::cli::commands::parse::ParseCommand; +use crate::parse::ParseCommand; #[derive(Parser, Debug)] #[command(next_line_help = true)] @@ -18,7 +18,7 @@ enum Commands { Parse(ParseCommand), } -pub fn execute() { +fn main() { match Cli::parse().command { Commands::Parse(command) => command.execute(), }; diff --git a/crates/codegen/runtime/cargo/src/runtime/cli/commands/parse.rs b/crates/solidity/outputs/cargo/cli/src/parse.rs similarity index 91% rename from crates/codegen/runtime/cargo/src/runtime/cli/commands/parse.rs rename to crates/solidity/outputs/cargo/cli/src/parse.rs index edf783852b..aaa93302d9 100644 --- a/crates/codegen/runtime/cargo/src/runtime/cli/commands/parse.rs +++ b/crates/solidity/outputs/cargo/cli/src/parse.rs @@ -2,9 +2,8 @@ use std::fs; use std::path::PathBuf; use semver::Version; - -use crate::diagnostic; -use crate::parser::Parser; +use slang_solidity::diagnostic; +use slang_solidity::parser::Parser; #[derive(clap::Parser, Debug)] pub struct ParseCommand { @@ -33,7 +32,7 @@ impl ParseCommand { .unwrap_or_else(|_| panic!("File not found: {file_path:?}")); let input = fs::read_to_string(&file_path).unwrap(); - let parser = Parser::new(version).unwrap(); + let parser = Parser::create(version).unwrap(); let parse_output = parser.parse(Parser::ROOT_KIND, &input); if !parse_output.is_valid() { diff --git a/crates/solidity/outputs/cargo/slang_solidity_cli/CHANGELOG.md b/crates/solidity/outputs/cargo/crate/CHANGELOG.md similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity_cli/CHANGELOG.md rename to crates/solidity/outputs/cargo/crate/CHANGELOG.md diff --git a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml b/crates/solidity/outputs/cargo/crate/Cargo.toml similarity index 82% rename from crates/solidity/outputs/cargo/slang_solidity/Cargo.toml rename to crates/solidity/outputs/cargo/crate/Cargo.toml index 628106a451..9aa011fa5b 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/Cargo.toml +++ b/crates/solidity/outputs/cargo/crate/Cargo.toml @@ -30,9 +30,8 @@ categories = [ [features] default = [] __experimental_bindings_api = ["dep:metaslang_bindings"] -__private_cli_execution = ["dep:ariadne", "dep:clap", "dep:serde_json"] -__private_testing_utils = ["dep:ariadne"] -__private_wit_bindings = ["dep:paste", "dep:wit-bindgen"] +__private_ariadne_errors = ["dep:ariadne"] +__private_testing_utils = [] [build-dependencies] # __REMOVE_THIS_LINE_DURING_CARGO_PUBLISH__ anyhow = { workspace = true } # __REMOVE_THIS_LINE_DURING_CARGO_PUBLISH__ @@ -42,17 +41,13 @@ solidity_language = { workspace = true } # __REMOVE_THIS_LINE_DURING_CAR [dependencies] ariadne = { workspace = true, optional = true } -clap = { workspace = true, optional = true } metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -paste = { workspace = true, optional = 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_cli/LICENSE b/crates/solidity/outputs/cargo/crate/LICENSE similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity_cli/LICENSE rename to crates/solidity/outputs/cargo/crate/LICENSE diff --git a/crates/solidity/outputs/cargo/slang_solidity/README.md b/crates/solidity/outputs/cargo/crate/README.md similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/README.md rename to crates/solidity/outputs/cargo/crate/README.md diff --git a/crates/solidity/outputs/cargo/slang_solidity/build.rs b/crates/solidity/outputs/cargo/crate/build.rs similarity index 61% rename from crates/solidity/outputs/cargo/slang_solidity/build.rs rename to crates/solidity/outputs/cargo/crate/build.rs index ba7114c8d8..4423ee5667 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/build.rs +++ b/crates/solidity/outputs/cargo/crate/build.rs @@ -2,14 +2,17 @@ //! It is removed when publishing to crates.io. use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; +use codegen_runtime_generator::RuntimeGenerator; use infra_utils::cargo::CargoWorkspace; use solidity_language::SolidityDefinition; fn main() -> Result<()> { let language = SolidityDefinition::create(); + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_cargo_crate")?.join("src/runtime"); + let output_dir = CargoWorkspace::locate_source_crate("slang_solidity")?.join("src/generated"); - OutputLanguage::Cargo.generate_runtime(&language, &output_dir) + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) } diff --git a/crates/solidity/outputs/cargo/slang_solidity/generated/public_api.txt b/crates/solidity/outputs/cargo/crate/generated/public_api.txt similarity index 99% rename from crates/solidity/outputs/cargo/slang_solidity/generated/public_api.txt rename to crates/solidity/outputs/cargo/crate/generated/public_api.txt index 52df7ec3e7..2a7e87b49a 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/generated/public_api.txt +++ b/crates/solidity/outputs/cargo/crate/generated/public_api.txt @@ -7,8 +7,6 @@ pub fn slang_solidity::bindings::get_binding_rules() -> &'static str pub type slang_solidity::bindings::Bindings = metaslang_bindings::Bindings pub type slang_solidity::bindings::Definition<'a> = metaslang_bindings::Definition<'a, slang_solidity::cst::KindTypes> pub type slang_solidity::bindings::Reference<'a> = metaslang_bindings::Reference<'a, slang_solidity::cst::KindTypes> -pub mod slang_solidity::cli -pub fn slang_solidity::cli::execute() pub mod slang_solidity::cst pub use slang_solidity::cst::EdgeLabelExtensions pub use slang_solidity::cst::NonterminalKindExtensions @@ -198,7 +196,7 @@ pub type slang_solidity::cst::KindTypes::TerminalKind = slang_solidity::cst::Ter impl serde::ser::Serialize for slang_solidity::cst::KindTypes pub fn slang_solidity::cst::KindTypes::serialize<__S>(&self, __serializer: __S) -> core::result::Result<<__S as serde::ser::Serializer>::Ok, <__S as serde::ser::Serializer>::Error> where __S: serde::ser::Serializer #[repr(u8)] pub enum slang_solidity::cst::NonterminalKind -pub slang_solidity::cst::NonterminalKind::ABICoderPragma +pub slang_solidity::cst::NonterminalKind::AbicoderPragma pub slang_solidity::cst::NonterminalKind::AdditiveExpression pub slang_solidity::cst::NonterminalKind::AddressType pub slang_solidity::cst::NonterminalKind::AndExpression @@ -916,12 +914,12 @@ impl core::fmt::Debug for slang_solidity::parser::ParseOutput pub fn slang_solidity::parser::ParseOutput::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result impl core::marker::StructuralPartialEq for slang_solidity::parser::ParseOutput pub struct slang_solidity::parser::Parser +pub slang_solidity::parser::Parser::version: semver::Version impl slang_solidity::parser::Parser pub const slang_solidity::parser::Parser::ROOT_KIND: slang_solidity::cst::NonterminalKind pub const slang_solidity::parser::Parser::SUPPORTED_VERSIONS: &'static [semver::Version] -pub fn slang_solidity::parser::Parser::new(version: semver::Version) -> core::result::Result +pub fn slang_solidity::parser::Parser::create(version: semver::Version) -> core::result::Result pub fn slang_solidity::parser::Parser::parse(&self, kind: slang_solidity::cst::NonterminalKind, input: &str) -> slang_solidity::parser::ParseOutput pub fn slang_solidity::parser::Parser::version(&self) -> &semver::Version impl core::fmt::Debug for slang_solidity::parser::Parser pub fn slang_solidity::parser::Parser::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -pub mod slang_solidity::wit diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs rename to crates/solidity/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/bindings/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs new file mode 100644 index 0000000000..88388f6449 --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs @@ -0,0 +1,157 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[strum(serialize_all = "snake_case")] +#[derive(Clone, Copy)] +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, + Minus, + MinusGreaterThan, + ModifierKeyword, + Name, + 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, + Variable, + VariableType, + Variables, + Version, + WhileKeyword, +} + +impl crate::cst::EdgeLabelExtensions for EdgeLabel {} diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs new file mode 100644 index 0000000000..4bfe3caedf --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs @@ -0,0 +1,42 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +/// The lexical context of the scanner. + +#[repr(u8)] +#[derive(strum_macros::FromRepr, Clone, Copy)] +pub(crate) enum LexicalContext { + Default, + Pragma, + Yul, +} + +/// Marker trait for type-level [`LexicalContext`] variants. +pub(crate) trait IsLexicalContext { + /// Returns a run-time [`LexicalContext`] value. + fn value() -> LexicalContext; +} + +#[allow(non_snake_case)] +pub(crate) mod LexicalContextType { + pub struct Default; + + impl super::IsLexicalContext for Default { + fn value() -> super::LexicalContext { + super::LexicalContext::Default + } + } + pub struct Pragma; + + impl super::IsLexicalContext for Pragma { + fn value() -> super::LexicalContext { + super::LexicalContext::Pragma + } + } + pub struct Yul; + + impl super::IsLexicalContext for Yul { + fn value() -> super::LexicalContext { + super::LexicalContext::Yul + } + } +} diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs new file mode 100644 index 0000000000..52ab2f49b5 --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs @@ -0,0 +1,240 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +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, + 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, + SimpleVersionLiteral, + 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, + VersionExpression, + VersionExpressionSet, + VersionExpressionSets, + VersionLiteral, + VersionOperator, + VersionPragma, + VersionRange, + VersionTerm, + WhileStatement, + YulArguments, + YulAssignmentOperator, + YulBlock, + YulBreakStatement, + YulBuiltInFunction, + YulColonAndEqual, + YulContinueStatement, + YulDefaultCase, + YulEqualAndColon, + YulExpression, + YulForStatement, + YulFunctionCallExpression, + YulFunctionDefinition, + YulIfStatement, + YulLabel, + YulLeaveStatement, + YulLiteral, + YulParameters, + YulParametersDeclaration, + YulPath, + YulPathComponent, + YulPaths, + YulReturnsDeclaration, + YulStackAssignmentOperator, + YulStackAssignmentStatement, + YulStatement, + YulStatements, + YulSwitchCase, + YulSwitchCases, + YulSwitchStatement, + YulValueCase, + YulVariableAssignmentStatement, + YulVariableDeclarationStatement, + YulVariableDeclarationValue, + YulVariableNames, +} + +impl crate::cst::NonterminalKindExtensions for NonterminalKind {} diff --git a/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs new file mode 100644 index 0000000000..37e3e33dd4 --- /dev/null +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs @@ -0,0 +1,409 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u16)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +#[allow(clippy::upper_case_acronyms)] +pub enum TerminalKind { + // Built-in: + UNRECOGNIZED, + MISSING, + + // 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, + EqualColon, + 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, + TransientKeyword, + 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 crate::cst::TerminalKindExtensions for TerminalKind { + fn is_trivia(&self) -> bool { + matches!(self, |Self::EndOfLine| Self::MultiLineComment + | Self::MultiLineNatSpecComment + | Self::SingleLineComment + | Self::SingleLineNatSpecComment + | Self::Whitespace) + } + + fn is_valid(&self) -> bool { + !matches!(self, Self::UNRECOGNIZED | Self::MISSING) + } +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/cst/mod.rs similarity index 80% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/cst/mod.rs index ccbf409bc6..9f169288b9 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/cst/mod.rs @@ -1,13 +1,21 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -#[path = "generated/kinds.rs"] -mod kinds; +#[path = "generated/edge_label.rs"] +mod edge_label; +#[path = "generated/lexical_context.rs"] +mod lexical_context; +#[path = "generated/nonterminal_kind.rs"] +mod nonterminal_kind; +#[path = "generated/terminal_kind.rs"] +mod terminal_kind; -pub use kinds::{EdgeLabel, NonterminalKind, TerminalKind}; -pub(crate) use kinds::{IsLexicalContext, LexicalContext, LexicalContextType}; +pub use edge_label::EdgeLabel; +pub(crate) use lexical_context::{IsLexicalContext, LexicalContext, LexicalContextType}; pub use metaslang_cst::kinds::{ EdgeLabelExtensions, NonterminalKindExtensions, TerminalKindExtensions, }; +pub use nonterminal_kind::NonterminalKind; +pub use terminal_kind::TerminalKind; // These derives are because default #[derive(...)] on a generic type implements only the trait // with default bounds also implied for the generic types as well, i.e. @@ -38,7 +46,8 @@ pub type Cursor = metaslang_cst::cursor::Cursor; pub type CursorWithEdges = metaslang_cst::cursor::CursorWithEdges; pub type Query = metaslang_cst::query::Query; +pub use metaslang_cst::query::QueryError; pub type QueryMatch = metaslang_cst::query::QueryMatch; pub type QueryMatchIterator = metaslang_cst::query::QueryMatchIterator; -pub use metaslang_cst::query::QueryError; + pub use metaslang_cst::text_index::{TextIndex, TextRange, TextRangeExtensions}; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/diagnostic/mod.rs similarity index 96% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/diagnostic/mod.rs index 3e06aaaf77..06882bea3f 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/diagnostic/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/diagnostic/mod.rs @@ -24,10 +24,7 @@ pub trait Diagnostic { fn message(&self) -> String; } -#[cfg(any( - feature = "__private_cli_execution", - feature = "__private_testing_utils" -))] +#[cfg(feature = "__private_ariadne_errors")] pub fn render(error: &D, source_id: &str, source: &str, with_color: bool) -> String { use ariadne::{Color, Config, Label, Report, ReportKind, Source}; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/mod.rs similarity index 52% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/mod.rs index 80a635d4af..4b9d48d9f9 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/mod.rs @@ -1,17 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +#[cfg(feature = "__experimental_bindings_api")] +pub mod bindings; pub mod cst; pub mod diagnostic; pub mod parser; - -#[cfg(feature = "__experimental_bindings_api")] -pub mod bindings; - -#[cfg(feature = "__private_cli_execution")] -pub mod cli; - -#[cfg(feature = "__private_napi_interfaces")] -pub mod napi_interface; - -#[cfg(feature = "__private_wit_bindings")] -pub mod wit; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/generated/parser.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs similarity index 99% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/generated/parser.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs index e63b80d559..ea2cdb9a52 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/generated/parser.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/parser/generated/parser.rs @@ -10,16 +10,12 @@ unused_imports )] -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; use semver::Version; use crate::cst; use crate::cst::{ EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -#[cfg(feature = "__private_napi_interfaces")] -use crate::napi_interface::parser::ParseOutput as NAPIParseOutput; use crate::parser::lexer::{KeywordScan, Lexer, ScannedTerminal}; use crate::parser::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, @@ -33,7 +29,6 @@ use crate::parser::scanner_macros::{ use crate::parser::ParseOutput; #[derive(Debug)] -#[cfg_attr(feature = "__private_napi_interfaces", napi(namespace = "parser"))] pub struct Parser { #[allow(dead_code)] pub(crate) version_is_at_least_0_4_11: bool, @@ -71,24 +66,13 @@ pub struct Parser { pub(crate) version_is_at_least_0_8_24: bool, pub(crate) version_is_at_least_0_8_25: bool, pub(crate) version_is_at_least_0_8_27: bool, - pub(crate) version: Version, + pub version: Version, } #[derive(thiserror::Error, Debug)] pub enum ParserInitializationError { #[error("Unsupported language version '{0}'.")] UnsupportedLanguageVersion(Version), - - #[cfg(feature = "__private_napi_interfaces")] - #[error("Invalid semantic version '{0}'.")] - InvalidSemanticVersion(String), -} - -#[cfg(feature = "__private_napi_interfaces")] -impl From for napi::Error { - fn from(value: ParserInitializationError) -> Self { - napi::Error::from_reason(value.to_string()) - } } impl Parser { @@ -179,7 +163,7 @@ impl Parser { pub const ROOT_KIND: NonterminalKind = NonterminalKind::SourceUnit; - pub fn new(version: Version) -> std::result::Result { + pub fn create(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, @@ -233,7 +217,7 @@ impl Parser { ********************************************/ #[allow(unused_assignments, unused_parens)] - fn abi_coder_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { + fn abicoder_pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { SequenceHelper::run(|mut seq| { seq.elem_labeled( EdgeLabel::AbicoderKeyword, @@ -251,7 +235,7 @@ impl Parser { )?; seq.finish() }) - .with_kind(NonterminalKind::ABICoderPragma) + .with_kind(NonterminalKind::AbicoderPragma) } #[allow(unused_assignments, unused_parens)] @@ -3970,7 +3954,7 @@ impl Parser { #[allow(unused_assignments, unused_parens)] fn pragma(&self, input: &mut ParserContext<'_>) -> ParserResult { ChoiceHelper::run(input, |mut choice, input| { - let result = self.abi_coder_pragma(input); + let result = self.abicoder_pragma(input); choice.consider(input, result)?; let result = self.experimental_pragma(input); choice.consider(input, result)?; @@ -9173,7 +9157,7 @@ impl Parser { pub fn parse(&self, kind: NonterminalKind, input: &str) -> ParseOutput { match kind { - NonterminalKind::ABICoderPragma => Self::abi_coder_pragma.parse(self, input), + NonterminalKind::AbicoderPragma => Self::abicoder_pragma.parse(self, input), NonterminalKind::AdditiveExpression => Self::additive_expression.parse(self, input), NonterminalKind::AddressType => Self::address_type.parse(self, input), NonterminalKind::AndExpression => Self::and_expression.parse(self, input), @@ -13549,47 +13533,3 @@ impl Lexer for Parser { } } } - -#[cfg(feature = "__private_napi_interfaces")] -// NAPI-exposed functions have to accept owned values. -#[allow(clippy::needless_pass_by_value)] -#[napi(namespace = "parser")] -impl Parser { - #[napi(constructor, catch_unwind)] - pub fn new_napi(version: String) -> std::result::Result { - let version = Version::parse(&version) - .map_err(|_| ParserInitializationError::InvalidSemanticVersion(version))?; - Self::new(version).map_err(|e| e.into()) - } - - #[napi(getter, js_name = "version", catch_unwind)] - pub fn version_napi(&self) -> String { - self.version.to_string() - } - - #[napi(js_name = "supportedVersions", catch_unwind)] - pub fn supported_versions_napi() -> Vec { - return Self::SUPPORTED_VERSIONS - .iter() - .map(|v| v.to_string()) - .collect(); - } - - #[napi( - js_name = "rootKind", - ts_return_type = "cst.NonterminalKind", - catch_unwind - )] - pub fn root_kind_napi() -> NonterminalKind { - Self::ROOT_KIND - } - - #[napi(js_name = "parse", ts_return_type = "parser.ParseOutput", catch_unwind)] - pub fn parse_napi( - &self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - input: String, - ) -> NAPIParseOutput { - self.parse(kind, input.as_str()).into() - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/lexer/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/lexer/mod.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/lexer/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/lexer/mod.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/mod.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/mod.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parse_error.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parse_error.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parse_error.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parse_error.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parse_output.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parse_output.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parse_output.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parse_output.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/choice_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/choice_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/choice_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/choice_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/context.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/context.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/context.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/context.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/mod.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/mod.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/optional_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/optional_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/optional_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/optional_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/parser_function.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/parser_function.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/parser_function.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/parser_function.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/parser_result.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/parser_result.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/parser_result.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/parser_result.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/precedence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/precedence_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/precedence_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/precedence_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/recovery.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/recovery.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/recovery.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/recovery.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/repetition_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/repetition_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/repetition_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/repetition_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/separated_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/separated_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/separated_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/separated_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/sequence_helper.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/sequence_helper.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/sequence_helper.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/parser_support/sequence_helper.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/scanner_macros/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/parser/scanner_macros/mod.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/scanner_macros/mod.rs rename to crates/solidity/outputs/cargo/crate/src/generated/parser/scanner_macros/mod.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/lib.rs b/crates/solidity/outputs/cargo/crate/src/lib.rs similarity index 100% rename from crates/solidity/outputs/cargo/slang_solidity/src/lib.rs rename to crates/solidity/outputs/cargo/crate/src/lib.rs diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/parse.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/parse.rs deleted file mode 100644 index 8c5a51610d..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/parse.rs +++ /dev/null @@ -1,60 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use std::fs; -use std::path::PathBuf; - -use semver::Version; - -use crate::diagnostic; -use crate::parser::Parser; - -#[derive(clap::Parser, Debug)] -pub struct ParseCommand { - /// File path to the source file to parse - file_path: PathBuf, - - /// The language version to use for parsing - #[arg(short, long)] - version: Version, - - /// Print the concrete syntax tree as JSON - #[clap(long)] - json: bool, -} - -impl ParseCommand { - pub fn execute(self) { - let Self { - file_path, - version, - json, - } = self; - - let file_path = file_path - .canonicalize() - .unwrap_or_else(|_| panic!("File not found: {file_path:?}")); - - let input = fs::read_to_string(&file_path).unwrap(); - let parser = Parser::new(version).unwrap(); - let parse_output = parser.parse(Parser::ROOT_KIND, &input); - - if !parse_output.is_valid() { - const COLOR: bool = true; - - let report = parse_output - .errors() - .iter() - .map(|error| diagnostic::render(error, file_path.to_str().unwrap(), &input, COLOR)) - .collect::>() - .join("\n"); - - panic!("Parse failed:\n{report}"); - } - - if json { - let json = serde_json::to_string_pretty(&parse_output.tree()).unwrap(); - - println!("{json}"); - } - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs deleted file mode 100644 index 4d7994dd92..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -mod commands; - -use clap::{Parser, Subcommand}; - -use crate::cli::commands::parse::ParseCommand; - -#[derive(Parser, Debug)] -#[command(next_line_help = true)] -#[command(author, about)] -struct Cli { - #[command(subcommand)] - command: Commands, -} - -#[derive(Subcommand, Debug)] -enum Commands { - /// Parses a source file, and outputs any syntax errors, or a JSON concrete syntax tree - Parse(ParseCommand), -} - -pub fn execute() { - match Cli::parse().command { - Commands::Parse(command) => command.execute(), - }; -} - -#[test] -fn verify_clap_cli() { - // Catches problems earlier in the development cycle: - ::command().debug_assert(); -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/generated/kinds.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/generated/kinds.rs deleted file mode 100644 index df20227976..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/generated/kinds.rs +++ /dev/null @@ -1,852 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -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, - 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, - SimpleVersionLiteral, - 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, - VersionExpression, - VersionExpressionSet, - VersionExpressionSets, - VersionLiteral, - VersionOperator, - VersionPragma, - VersionRange, - VersionTerm, - WhileStatement, - YulArguments, - YulAssignmentOperator, - YulBlock, - YulBreakStatement, - YulBuiltInFunction, - YulColonAndEqual, - YulContinueStatement, - YulDefaultCase, - YulEqualAndColon, - YulExpression, - YulForStatement, - YulFunctionCallExpression, - YulFunctionDefinition, - YulIfStatement, - YulLabel, - YulLeaveStatement, - YulLiteral, - YulParameters, - YulParametersDeclaration, - YulPath, - YulPathComponent, - YulPaths, - YulReturnsDeclaration, - YulStackAssignmentOperator, - YulStackAssignmentStatement, - YulStatement, - YulStatements, - YulSwitchCase, - YulSwitchCases, - YulSwitchStatement, - YulValueCase, - YulVariableAssignmentStatement, - YulVariableDeclarationStatement, - YulVariableDeclarationValue, - YulVariableNames, -} - -impl crate::cst::NonterminalKindExtensions for NonterminalKind {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[strum(serialize_all = "snake_case")] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -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, - Minus, - MinusGreaterThan, - ModifierKeyword, - Name, - 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, - Variable, - VariableType, - Variables, - Version, - WhileKeyword, -} - -impl crate::cst::EdgeLabelExtensions for EdgeLabel {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u16)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -#[allow(clippy::upper_case_acronyms)] -pub enum TerminalKind { - // Built-in: - UNRECOGNIZED, - MISSING, - - // 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, - EqualColon, - 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, - TransientKeyword, - 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 crate::cst::TerminalKindExtensions for TerminalKind { - fn is_trivia(&self) -> bool { - matches!(self, |Self::EndOfLine| Self::MultiLineComment - | Self::MultiLineNatSpecComment - | Self::SingleLineComment - | Self::SingleLineNatSpecComment - | Self::Whitespace) - } - - fn is_valid(&self) -> bool { - !matches!(self, Self::UNRECOGNIZED | Self::MISSING) - } -} - -/// 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, - Pragma, - Yul, -} - -/// Marker trait for type-level [`LexicalContext`] variants. -pub(crate) trait IsLexicalContext { - /// Returns a run-time [`LexicalContext`] value. - fn value() -> LexicalContext; -} - -#[allow(non_snake_case)] -pub(crate) mod LexicalContextType { - pub struct Default; - - impl super::IsLexicalContext for Default { - fn value() -> super::LexicalContext { - super::LexicalContext::Default - } - } - pub struct Pragma; - - impl super::IsLexicalContext for Pragma { - fn value() -> super::LexicalContext { - super::LexicalContext::Pragma - } - } - pub struct Yul; - - impl super::IsLexicalContext for Yul { - fn value() -> super::LexicalContext { - super::LexicalContext::Yul - } - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs deleted file mode 100644 index aa8584a3c5..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs +++ /dev/null @@ -1,482 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// NAPI-exposed functions have to accept owned values -#![allow(clippy::needless_pass_by_value)] -// The functions are meant to be definitions for export, so they're not really used -#![allow(clippy::return_self_not_must_use)] - -use std::collections::HashMap; -use std::rc::Rc; - -use napi::bindgen_prelude::ClassInstance; -use napi::{Either, Env}; -use napi_derive::napi; - -use crate::napi_interface::{ - EdgeLabel, NonterminalKind, RustCursor, RustNode, RustNonterminalNode, RustQuery, - RustQueryMatch, RustQueryMatchIterator, RustTerminalNode, RustTextIndex, RustTextRange, - TerminalKind, -}; - -#[napi(namespace = "cst", string_enum)] -pub enum NodeType { - Nonterminal, - Terminal, -} - -pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; -} - -impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `NonterminalNode | TerminalNode` JS object. - fn into_js_either_node(self) -> Either { - match self { - RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), - RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), - } - } -} - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct NonterminalNode(pub(crate) Rc); - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct TerminalNode(pub(crate) Rc); - -#[napi(namespace = "cst")] -impl NonterminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Nonterminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Nonterminal - } - - #[napi(getter, ts_return_type = "cst.NonterminalKind", catch_unwind)] - pub fn kind(&self) -> NonterminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - self.0.text_len.into() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { - self.0 - .children - .iter() - .map(|child| child.node.clone().into_js_either_node()) - .collect() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Nonterminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(catch_unwind)] - pub fn unparse(&self) -> String { - Rc::clone(&self.0).unparse() - } - - // Expose the children as a hidden (non-enumerable, don't generate type definition) - // property that's eagerly evaluated (getter) for an inspected parent object in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__children", // Needed; otherwise, the property name would shadow `children`. - skip_typescript, - catch_unwind - )] - pub fn __children(&self) -> Vec> { - Self::children(self) - } - - // Similarly, expose the eagerly evaluated unparsed text in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__text", - skip_typescript, - catch_unwind - )] - pub fn __text(&self) -> String { - self.unparse() - } -} - -#[napi(namespace = "cst")] -impl TerminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Terminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Terminal - } - - #[napi(getter, ts_return_type = "cst.TerminalKind", catch_unwind)] - pub fn kind(&self) -> TerminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - let text_len: RustTextIndex = (&self.0.text).into(); - text_len.into() - } - - #[napi(getter, catch_unwind)] - pub fn text(&self) -> String { - self.0.text.clone() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Terminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } -} - -#[napi(namespace = "cst")] -pub struct Cursor(pub(super) RustCursor); - -impl From for Cursor { - fn from(value: RustCursor) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Cursor { - pub(crate) fn new(cursor: RustCursor) -> Self { - Self(cursor) - } - - #[napi(catch_unwind)] - pub fn reset(&mut self) { - self.0.reset(); - } - - #[napi(catch_unwind)] - pub fn complete(&mut self) { - self.0.complete(); - } - - #[must_use] - #[napi(catch_unwind)] - #[allow(clippy::should_implement_trait)] // These are meant to be explicitly exposed to NAPI - pub fn clone(&self) -> Self { - Self(self.0.clone()) - } - - #[must_use] - #[napi(catch_unwind)] - pub fn spawn(&self) -> Self { - Self::new(self.0.spawn()) - } - - #[napi(getter, catch_unwind)] - pub fn is_completed(&self) -> bool { - self.0.is_completed() - } - - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { - self.0.node().into_js_either_node() - } - - #[napi(getter, ts_return_type = "cst.EdgeLabel", catch_unwind)] - pub fn label(&self) -> Option { - self.0.label() - } - - #[napi(getter, ts_return_type = "cst.TextIndex", catch_unwind)] - pub fn text_offset(&self) -> TextIndex { - self.0.text_offset().into() - } - - #[napi(getter, ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 - #[napi(getter, catch_unwind)] - pub fn depth(&self) -> u32 { - self.0.depth() as u32 - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(NonterminalNode).collect() - } - - #[napi(catch_unwind)] - pub fn go_to_next(&mut self) -> bool { - self.0.go_to_next() - } - - #[napi(catch_unwind)] - pub fn go_to_next_non_descendent(&mut self) -> bool { - self.0.go_to_next_non_descendent() - } - - #[napi(catch_unwind)] - pub fn go_to_previous(&mut self) -> bool { - self.0.go_to_previous() - } - - #[napi(catch_unwind)] - pub fn go_to_parent(&mut self) -> bool { - self.0.go_to_parent() - } - - #[napi(catch_unwind)] - pub fn go_to_first_child(&mut self) -> bool { - self.0.go_to_first_child() - } - - #[napi(catch_unwind)] - pub fn go_to_last_child(&mut self) -> bool { - self.0.go_to_last_child() - } - - #[napi(catch_unwind)] - pub fn go_to_nth_child(&mut self, child_number: u32) -> bool { - self.0.go_to_nth_child(child_number as usize) - } - - #[napi(catch_unwind)] - pub fn go_to_next_sibling(&mut self) -> bool { - self.0.go_to_next_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_previous_sibling(&mut self) -> bool { - self.0.go_to_previous_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal(&mut self) -> bool { - self.0.go_to_next_terminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.TerminalKind")] kind: TerminalKind, - ) -> bool { - self.0.go_to_next_terminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_terminal_with_kinds(&kinds) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal(&mut self) -> bool { - self.0.go_to_next_nonterminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - ) -> bool { - self.0.go_to_next_nonterminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_nonterminal_with_kinds(&kinds) - } -} - -#[napi(namespace = "cst")] -pub struct Query(RustQuery); - -impl From for Query { - fn from(value: RustQuery) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Query { - #[napi(factory, catch_unwind)] - pub fn parse(text: String) -> napi::Result { - RustQuery::parse(text.as_str()).map_or_else( - |err| Err(napi::Error::from_reason(err.message)), - |query| Ok(query.into()), - ) - } -} - -#[napi(namespace = "cst")] -pub struct QueryMatchIterator(RustQueryMatchIterator); - -#[napi(object, namespace = "cst")] -pub struct QueryMatch { - pub query_number: u32, - #[napi(ts_type = "{ [key: string]: cst.Cursor[] }")] - pub captures: HashMap>>, -} - -impl QueryMatch { - fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { - #[allow(clippy::cast_possible_truncation)] - let query_number = r#match.query_number as u32; - // transfer all of the captures eagerly on the assumption - // that they've all been explicitly requested. - let captures = r#match - .captures - .into_iter() - .map(|(key, values)| { - let instances = values - .into_iter() - .map(|cursor| Cursor(cursor).into_instance(env)) - .collect::>()?; - - Ok((key, instances)) - }) - .collect::>()?; - - Ok(Self { - query_number, - captures, - }) - } -} - -impl From for QueryMatchIterator { - fn from(value: RustQueryMatchIterator) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl QueryMatchIterator { - #[napi(catch_unwind)] - pub fn next(&mut self, env: Env) -> napi::Result> { - match self.0.next() { - Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), - None => Ok(None), - } - } -} - -#[napi(namespace = "cst")] -impl Cursor { - #[napi(ts_return_type = "cst.QueryMatchIterator", catch_unwind)] - pub fn query( - &self, - #[napi(ts_arg_type = "Array")] queries: Vec<&Query>, - ) -> QueryMatchIterator { - self.0 - .clone() - .query(queries.into_iter().map(|x| x.0.clone()).collect()) - .into() - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextIndex { - pub utf8: u32, - pub utf16: u32, - pub line: u32, - pub column: u32, -} - -impl From for TextIndex { - fn from(value: RustTextIndex) -> Self { - // We only support 32-byte indices on TS side. - #[allow(clippy::cast_possible_truncation)] - Self { - utf8: value.utf8 as u32, - utf16: value.utf16 as u32, - line: value.line as u32, - column: value.column as u32, - } - } -} - -impl From for RustTextIndex { - fn from(value: TextIndex) -> Self { - Self { - utf8: value.utf8 as usize, - utf16: value.utf16 as usize, - line: value.line as usize, - column: value.column as usize, - } - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextRange { - pub start: TextIndex, - pub end: TextIndex, -} - -impl From for TextRange { - fn from(value: RustTextRange) -> Self { - Self { - start: value.start.into(), - end: value.end.into(), - } - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs deleted file mode 100644 index 36f389892d..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/diagnostic.rs +++ /dev/null @@ -1,80 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use napi_derive::napi; - -use crate::napi_interface::cst::TextRange; - -/// Severity of the compiler diagnostic. -/// -/// Explicitly compatible with the LSP protocol. -#[napi(namespace = "diagnostic")] -pub enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, -} - -impl From for Severity { - fn from(value: crate::diagnostic::Severity) -> Severity { - match value { - crate::diagnostic::Severity::Error => Self::Error, - crate::diagnostic::Severity::Warning => Self::Warning, - crate::diagnostic::Severity::Information => Self::Information, - crate::diagnostic::Severity::Hint => Self::Hint, - } - } -} - -/// A compiler diagnostic that can be rendered to a user. -#[napi(namespace = "diagnostic")] -pub struct Diagnostic(pub(crate) Box); - -#[napi(namespace = "diagnostic")] -impl Diagnostic { - /// The severity of this diagnostic. - #[napi] - pub fn severity(&self) -> Severity { - self.0.severity().into() - } - - /// The character range of the source that this diagnostic applies to. - #[napi(ts_return_type = "cst.TextRange")] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - /// The primary message associated with this diagnostic. - #[napi] - pub fn message(&self) -> String { - self.0.message() - } -} - -/// Exposes the [`Diagnostic`](crate::diagnostic::Diagnostic) methods implemented for a given type -/// as regular N-API functions, satisfying the custom `DiagnosticInterface` interface on the N-API side. -// NOTE(#987): This is required because we can't directly expose the trait using `#[napi]` or expose -// an interface that has only methods defined. -// To not require explicit conversions, we define the interface ourselves and expose the relevant methods to satisfy it. -#[macro_export] -macro_rules! expose_diagnostic_trait_interface { - ($namespace:literal, $diagnostic:ty) => { - #[napi(namespace = $namespace)] - impl $diagnostic { - #[napi(ts_return_type = "diagnostic.Severity", catch_unwind)] - pub fn severity(&self) -> $crate::napi_interface::diagnostic::Severity { - $crate::diagnostic::Diagnostic::severity(&self.0).into() - } - - #[napi(ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> $crate::napi_interface::cst::TextRange { - $crate::diagnostic::Diagnostic::text_range(&self.0).into() - } - - #[napi] - pub fn message(&self) -> String { - $crate::diagnostic::Diagnostic::message(&self.0) - } - } - }; -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs deleted file mode 100644 index 625415e787..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/generated/ast_selectors.rs +++ /dev/null @@ -1,1928 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#![allow(clippy::too_many_lines)] // large match statements for all non-terminals -#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling - -use std::rc::Rc; - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::{EdgeLabel, NonterminalKind, RustEdge, RustNode, RustNonterminalNode}; - -// -// Sequences: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - let mut selector = Selector::new(node); - - let result = match node.kind() { - NonterminalKind::SourceUnit => selector.source_unit_sequence()?, - NonterminalKind::PragmaDirective => selector.pragma_directive_sequence()?, - NonterminalKind::ABICoderPragma => selector.abi_coder_pragma_sequence()?, - NonterminalKind::ExperimentalPragma => selector.experimental_pragma_sequence()?, - NonterminalKind::VersionPragma => selector.version_pragma_sequence()?, - NonterminalKind::VersionRange => selector.version_range_sequence()?, - NonterminalKind::VersionTerm => selector.version_term_sequence()?, - NonterminalKind::ImportDirective => selector.import_directive_sequence()?, - NonterminalKind::PathImport => selector.path_import_sequence()?, - NonterminalKind::NamedImport => selector.named_import_sequence()?, - NonterminalKind::ImportDeconstruction => selector.import_deconstruction_sequence()?, - NonterminalKind::ImportDeconstructionSymbol => { - selector.import_deconstruction_symbol_sequence()? - } - NonterminalKind::ImportAlias => selector.import_alias_sequence()?, - NonterminalKind::UsingDirective => selector.using_directive_sequence()?, - NonterminalKind::UsingDeconstruction => selector.using_deconstruction_sequence()?, - NonterminalKind::UsingDeconstructionSymbol => { - selector.using_deconstruction_symbol_sequence()? - } - NonterminalKind::UsingAlias => selector.using_alias_sequence()?, - NonterminalKind::ContractDefinition => selector.contract_definition_sequence()?, - NonterminalKind::InheritanceSpecifier => selector.inheritance_specifier_sequence()?, - NonterminalKind::InheritanceType => selector.inheritance_type_sequence()?, - NonterminalKind::InterfaceDefinition => selector.interface_definition_sequence()?, - NonterminalKind::LibraryDefinition => selector.library_definition_sequence()?, - NonterminalKind::StructDefinition => selector.struct_definition_sequence()?, - NonterminalKind::StructMember => selector.struct_member_sequence()?, - NonterminalKind::EnumDefinition => selector.enum_definition_sequence()?, - NonterminalKind::ConstantDefinition => selector.constant_definition_sequence()?, - NonterminalKind::StateVariableDefinition => { - selector.state_variable_definition_sequence()? - } - NonterminalKind::StateVariableDefinitionValue => { - selector.state_variable_definition_value_sequence()? - } - NonterminalKind::FunctionDefinition => selector.function_definition_sequence()?, - NonterminalKind::ParametersDeclaration => selector.parameters_declaration_sequence()?, - NonterminalKind::Parameter => selector.parameter_sequence()?, - NonterminalKind::OverrideSpecifier => selector.override_specifier_sequence()?, - NonterminalKind::OverridePathsDeclaration => { - selector.override_paths_declaration_sequence()? - } - NonterminalKind::ReturnsDeclaration => selector.returns_declaration_sequence()?, - NonterminalKind::ConstructorDefinition => selector.constructor_definition_sequence()?, - NonterminalKind::UnnamedFunctionDefinition => { - selector.unnamed_function_definition_sequence()? - } - NonterminalKind::FallbackFunctionDefinition => { - selector.fallback_function_definition_sequence()? - } - NonterminalKind::ReceiveFunctionDefinition => { - selector.receive_function_definition_sequence()? - } - NonterminalKind::ModifierDefinition => selector.modifier_definition_sequence()?, - NonterminalKind::ModifierInvocation => selector.modifier_invocation_sequence()?, - NonterminalKind::EventDefinition => selector.event_definition_sequence()?, - NonterminalKind::EventParametersDeclaration => { - selector.event_parameters_declaration_sequence()? - } - NonterminalKind::EventParameter => selector.event_parameter_sequence()?, - NonterminalKind::UserDefinedValueTypeDefinition => { - selector.user_defined_value_type_definition_sequence()? - } - NonterminalKind::ErrorDefinition => selector.error_definition_sequence()?, - NonterminalKind::ErrorParametersDeclaration => { - selector.error_parameters_declaration_sequence()? - } - NonterminalKind::ErrorParameter => selector.error_parameter_sequence()?, - NonterminalKind::ArrayTypeName => selector.array_type_name_sequence()?, - NonterminalKind::FunctionType => selector.function_type_sequence()?, - NonterminalKind::MappingType => selector.mapping_type_sequence()?, - NonterminalKind::MappingKey => selector.mapping_key_sequence()?, - NonterminalKind::MappingValue => selector.mapping_value_sequence()?, - NonterminalKind::AddressType => selector.address_type_sequence()?, - NonterminalKind::Block => selector.block_sequence()?, - NonterminalKind::UncheckedBlock => selector.unchecked_block_sequence()?, - NonterminalKind::ExpressionStatement => selector.expression_statement_sequence()?, - NonterminalKind::AssemblyStatement => selector.assembly_statement_sequence()?, - NonterminalKind::AssemblyFlagsDeclaration => { - selector.assembly_flags_declaration_sequence()? - } - NonterminalKind::TupleDeconstructionStatement => { - selector.tuple_deconstruction_statement_sequence()? - } - NonterminalKind::TupleDeconstructionElement => { - selector.tuple_deconstruction_element_sequence()? - } - NonterminalKind::TypedTupleMember => selector.typed_tuple_member_sequence()?, - NonterminalKind::UntypedTupleMember => selector.untyped_tuple_member_sequence()?, - NonterminalKind::VariableDeclarationStatement => { - selector.variable_declaration_statement_sequence()? - } - NonterminalKind::VariableDeclarationValue => { - selector.variable_declaration_value_sequence()? - } - NonterminalKind::IfStatement => selector.if_statement_sequence()?, - NonterminalKind::ElseBranch => selector.else_branch_sequence()?, - NonterminalKind::ForStatement => selector.for_statement_sequence()?, - NonterminalKind::WhileStatement => selector.while_statement_sequence()?, - NonterminalKind::DoWhileStatement => selector.do_while_statement_sequence()?, - NonterminalKind::ContinueStatement => selector.continue_statement_sequence()?, - NonterminalKind::BreakStatement => selector.break_statement_sequence()?, - NonterminalKind::ReturnStatement => selector.return_statement_sequence()?, - NonterminalKind::EmitStatement => selector.emit_statement_sequence()?, - NonterminalKind::TryStatement => selector.try_statement_sequence()?, - NonterminalKind::CatchClause => selector.catch_clause_sequence()?, - NonterminalKind::CatchClauseError => selector.catch_clause_error_sequence()?, - NonterminalKind::RevertStatement => selector.revert_statement_sequence()?, - NonterminalKind::ThrowStatement => selector.throw_statement_sequence()?, - NonterminalKind::AssignmentExpression => selector.assignment_expression_sequence()?, - NonterminalKind::ConditionalExpression => selector.conditional_expression_sequence()?, - NonterminalKind::OrExpression => selector.or_expression_sequence()?, - NonterminalKind::AndExpression => selector.and_expression_sequence()?, - NonterminalKind::EqualityExpression => selector.equality_expression_sequence()?, - NonterminalKind::ComparisonExpression => selector.comparison_expression_sequence()?, - NonterminalKind::BitwiseOrExpression => selector.bitwise_or_expression_sequence()?, - NonterminalKind::BitwiseXorExpression => selector.bitwise_xor_expression_sequence()?, - NonterminalKind::BitwiseAndExpression => selector.bitwise_and_expression_sequence()?, - NonterminalKind::ShiftExpression => selector.shift_expression_sequence()?, - NonterminalKind::AdditiveExpression => selector.additive_expression_sequence()?, - NonterminalKind::MultiplicativeExpression => { - selector.multiplicative_expression_sequence()? - } - NonterminalKind::ExponentiationExpression => { - selector.exponentiation_expression_sequence()? - } - NonterminalKind::PostfixExpression => selector.postfix_expression_sequence()?, - NonterminalKind::PrefixExpression => selector.prefix_expression_sequence()?, - NonterminalKind::FunctionCallExpression => selector.function_call_expression_sequence()?, - NonterminalKind::CallOptionsExpression => selector.call_options_expression_sequence()?, - NonterminalKind::MemberAccessExpression => selector.member_access_expression_sequence()?, - NonterminalKind::IndexAccessExpression => selector.index_access_expression_sequence()?, - NonterminalKind::IndexAccessEnd => selector.index_access_end_sequence()?, - NonterminalKind::PositionalArgumentsDeclaration => { - selector.positional_arguments_declaration_sequence()? - } - NonterminalKind::NamedArgumentsDeclaration => { - selector.named_arguments_declaration_sequence()? - } - NonterminalKind::NamedArgumentGroup => selector.named_argument_group_sequence()?, - NonterminalKind::NamedArgument => selector.named_argument_sequence()?, - NonterminalKind::TypeExpression => selector.type_expression_sequence()?, - NonterminalKind::NewExpression => selector.new_expression_sequence()?, - NonterminalKind::TupleExpression => selector.tuple_expression_sequence()?, - NonterminalKind::TupleValue => selector.tuple_value_sequence()?, - NonterminalKind::ArrayExpression => selector.array_expression_sequence()?, - NonterminalKind::HexNumberExpression => selector.hex_number_expression_sequence()?, - NonterminalKind::DecimalNumberExpression => { - selector.decimal_number_expression_sequence()? - } - NonterminalKind::YulBlock => selector.yul_block_sequence()?, - NonterminalKind::YulFunctionDefinition => selector.yul_function_definition_sequence()?, - NonterminalKind::YulParametersDeclaration => { - selector.yul_parameters_declaration_sequence()? - } - NonterminalKind::YulReturnsDeclaration => selector.yul_returns_declaration_sequence()?, - NonterminalKind::YulVariableDeclarationStatement => { - selector.yul_variable_declaration_statement_sequence()? - } - NonterminalKind::YulVariableDeclarationValue => { - selector.yul_variable_declaration_value_sequence()? - } - NonterminalKind::YulVariableAssignmentStatement => { - selector.yul_variable_assignment_statement_sequence()? - } - NonterminalKind::YulColonAndEqual => selector.yul_colon_and_equal_sequence()?, - NonterminalKind::YulStackAssignmentStatement => { - selector.yul_stack_assignment_statement_sequence()? - } - NonterminalKind::YulEqualAndColon => selector.yul_equal_and_colon_sequence()?, - NonterminalKind::YulIfStatement => selector.yul_if_statement_sequence()?, - NonterminalKind::YulForStatement => selector.yul_for_statement_sequence()?, - NonterminalKind::YulSwitchStatement => selector.yul_switch_statement_sequence()?, - NonterminalKind::YulDefaultCase => selector.yul_default_case_sequence()?, - NonterminalKind::YulValueCase => selector.yul_value_case_sequence()?, - NonterminalKind::YulLeaveStatement => selector.yul_leave_statement_sequence()?, - NonterminalKind::YulBreakStatement => selector.yul_break_statement_sequence()?, - NonterminalKind::YulContinueStatement => selector.yul_continue_statement_sequence()?, - NonterminalKind::YulLabel => selector.yul_label_sequence()?, - NonterminalKind::YulFunctionCallExpression => { - selector.yul_function_call_expression_sequence()? - } - _ => { - return Error::UnexpectedParent(node.kind()).into(); - } - }; - - selector.finalize()?; - Ok(result) -} -impl Selector { - fn source_unit_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![Some(self.select(EdgeLabel::Members)?)]) - } -} - -impl Selector { - fn pragma_directive_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::PragmaKeyword)?), - Some(self.select(EdgeLabel::Pragma)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn abi_coder_pragma_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::AbicoderKeyword)?), - Some(self.select(EdgeLabel::Version)?), - ]) - } -} - -impl Selector { - fn experimental_pragma_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ExperimentalKeyword)?), - Some(self.select(EdgeLabel::Feature)?), - ]) - } -} - -impl Selector { - fn version_pragma_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::SolidityKeyword)?), - Some(self.select(EdgeLabel::Sets)?), - ]) - } -} - -impl Selector { - fn version_range_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Start)?), - Some(self.select(EdgeLabel::Minus)?), - Some(self.select(EdgeLabel::End)?), - ]) - } -} - -impl Selector { - fn version_term_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - self.try_select(EdgeLabel::Operator), - Some(self.select(EdgeLabel::Literal)?), - ]) - } -} - -impl Selector { - fn import_directive_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ImportKeyword)?), - Some(self.select(EdgeLabel::Clause)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn path_import_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Path)?), - self.try_select(EdgeLabel::Alias), - ]) - } -} - -impl Selector { - fn named_import_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Asterisk)?), - Some(self.select(EdgeLabel::Alias)?), - Some(self.select(EdgeLabel::FromKeyword)?), - Some(self.select(EdgeLabel::Path)?), - ]) - } -} - -impl Selector { - fn import_deconstruction_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Symbols)?), - Some(self.select(EdgeLabel::CloseBrace)?), - Some(self.select(EdgeLabel::FromKeyword)?), - Some(self.select(EdgeLabel::Path)?), - ]) - } -} - -impl Selector { - fn import_deconstruction_symbol_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Alias), - ]) - } -} - -impl Selector { - fn import_alias_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::AsKeyword)?), - Some(self.select(EdgeLabel::Identifier)?), - ]) - } -} - -impl Selector { - fn using_directive_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::UsingKeyword)?), - Some(self.select(EdgeLabel::Clause)?), - Some(self.select(EdgeLabel::ForKeyword)?), - Some(self.select(EdgeLabel::Target)?), - self.try_select(EdgeLabel::GlobalKeyword), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn using_deconstruction_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Symbols)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn using_deconstruction_symbol_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Alias), - ]) - } -} - -impl Selector { - fn using_alias_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::AsKeyword)?), - Some(self.select(EdgeLabel::Operator)?), - ]) - } -} - -impl Selector { - fn contract_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - self.try_select(EdgeLabel::AbstractKeyword), - Some(self.select(EdgeLabel::ContractKeyword)?), - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Inheritance), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn inheritance_specifier_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::IsKeyword)?), - Some(self.select(EdgeLabel::Types)?), - ]) - } -} - -impl Selector { - fn inheritance_type_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::Arguments), - ]) - } -} - -impl Selector { - fn interface_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::InterfaceKeyword)?), - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Inheritance), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn library_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LibraryKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn struct_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::StructKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn struct_member_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn enum_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::EnumKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn constant_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - Some(self.select(EdgeLabel::ConstantKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Equal)?), - Some(self.select(EdgeLabel::Value)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn state_variable_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - Some(self.select(EdgeLabel::Attributes)?), - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Value), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn state_variable_definition_value_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Equal)?), - Some(self.select(EdgeLabel::Value)?), - ]) - } -} - -impl Selector { - fn function_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::FunctionKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - self.try_select(EdgeLabel::Returns), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn parameters_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn parameter_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::StorageLocation), - self.try_select(EdgeLabel::Name), - ]) - } -} - -impl Selector { - fn override_specifier_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OverrideKeyword)?), - self.try_select(EdgeLabel::Overridden), - ]) - } -} - -impl Selector { - fn override_paths_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Paths)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn returns_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ReturnsKeyword)?), - Some(self.select(EdgeLabel::Variables)?), - ]) - } -} - -impl Selector { - fn constructor_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ConstructorKeyword)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn unnamed_function_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::FunctionKeyword)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn fallback_function_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::FallbackKeyword)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - self.try_select(EdgeLabel::Returns), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn receive_function_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ReceiveKeyword)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn modifier_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ModifierKeyword)?), - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Parameters), - Some(self.select(EdgeLabel::Attributes)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn modifier_invocation_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Arguments), - ]) - } -} - -impl Selector { - fn event_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::EventKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Parameters)?), - self.try_select(EdgeLabel::AnonymousKeyword), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn event_parameters_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn event_parameter_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::IndexedKeyword), - self.try_select(EdgeLabel::Name), - ]) - } -} - -impl Selector { - fn user_defined_value_type_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::IsKeyword)?), - Some(self.select(EdgeLabel::ValueType)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn error_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ErrorKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn error_parameters_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn error_parameter_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::Name), - ]) - } -} - -impl Selector { - fn array_type_name_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::OpenBracket)?), - self.try_select(EdgeLabel::Index), - Some(self.select(EdgeLabel::CloseBracket)?), - ]) - } -} - -impl Selector { - fn function_type_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::FunctionKeyword)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::Attributes)?), - self.try_select(EdgeLabel::Returns), - ]) - } -} - -impl Selector { - fn mapping_type_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::MappingKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::KeyType)?), - Some(self.select(EdgeLabel::EqualGreaterThan)?), - Some(self.select(EdgeLabel::ValueType)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn mapping_key_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::KeyType)?), - self.try_select(EdgeLabel::Name), - ]) - } -} - -impl Selector { - fn mapping_value_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::Name), - ]) - } -} - -impl Selector { - fn address_type_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::AddressKeyword)?), - self.try_select(EdgeLabel::PayableKeyword), - ]) - } -} - -impl Selector { - fn block_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Statements)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn unchecked_block_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::UncheckedKeyword)?), - Some(self.select(EdgeLabel::Block)?), - ]) - } -} - -impl Selector { - fn expression_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Expression)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn assembly_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::AssemblyKeyword)?), - self.try_select(EdgeLabel::Label), - self.try_select(EdgeLabel::Flags), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn assembly_flags_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Flags)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn tuple_deconstruction_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - self.try_select(EdgeLabel::VarKeyword), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Elements)?), - Some(self.select(EdgeLabel::CloseParen)?), - Some(self.select(EdgeLabel::Equal)?), - Some(self.select(EdgeLabel::Expression)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn tuple_deconstruction_element_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![self.try_select(EdgeLabel::Member)]) - } -} - -impl Selector { - fn typed_tuple_member_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeName)?), - self.try_select(EdgeLabel::StorageLocation), - Some(self.select(EdgeLabel::Name)?), - ]) - } -} - -impl Selector { - fn untyped_tuple_member_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - self.try_select(EdgeLabel::StorageLocation), - Some(self.select(EdgeLabel::Name)?), - ]) - } -} - -impl Selector { - fn variable_declaration_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::VariableType)?), - self.try_select(EdgeLabel::StorageLocation), - Some(self.select(EdgeLabel::Name)?), - self.try_select(EdgeLabel::Value), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn variable_declaration_value_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Equal)?), - Some(self.select(EdgeLabel::Expression)?), - ]) - } -} - -impl Selector { - fn if_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::IfKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Condition)?), - Some(self.select(EdgeLabel::CloseParen)?), - Some(self.select(EdgeLabel::Body)?), - self.try_select(EdgeLabel::ElseBranch), - ]) - } -} - -impl Selector { - fn else_branch_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ElseKeyword)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn for_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ForKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Initialization)?), - Some(self.select(EdgeLabel::Condition)?), - self.try_select(EdgeLabel::Iterator), - Some(self.select(EdgeLabel::CloseParen)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn while_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::WhileKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Condition)?), - Some(self.select(EdgeLabel::CloseParen)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn do_while_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::DoKeyword)?), - Some(self.select(EdgeLabel::Body)?), - Some(self.select(EdgeLabel::WhileKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Condition)?), - Some(self.select(EdgeLabel::CloseParen)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn continue_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ContinueKeyword)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn break_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::BreakKeyword)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn return_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ReturnKeyword)?), - self.try_select(EdgeLabel::Expression), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn emit_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::EmitKeyword)?), - Some(self.select(EdgeLabel::Event)?), - Some(self.select(EdgeLabel::Arguments)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn try_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TryKeyword)?), - Some(self.select(EdgeLabel::Expression)?), - self.try_select(EdgeLabel::Returns), - Some(self.select(EdgeLabel::Body)?), - Some(self.select(EdgeLabel::CatchClauses)?), - ]) - } -} - -impl Selector { - fn catch_clause_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::CatchKeyword)?), - self.try_select(EdgeLabel::Error), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn catch_clause_error_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - self.try_select(EdgeLabel::Name), - Some(self.select(EdgeLabel::Parameters)?), - ]) - } -} - -impl Selector { - fn revert_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::RevertKeyword)?), - self.try_select(EdgeLabel::Error), - Some(self.select(EdgeLabel::Arguments)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn throw_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ThrowKeyword)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn assignment_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn conditional_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::QuestionMark)?), - Some(self.select(EdgeLabel::TrueExpression)?), - Some(self.select(EdgeLabel::Colon)?), - Some(self.select(EdgeLabel::FalseExpression)?), - ]) - } -} - -impl Selector { - fn or_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn and_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn equality_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn comparison_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn bitwise_or_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn bitwise_xor_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn bitwise_and_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn shift_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn additive_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn multiplicative_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn exponentiation_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn postfix_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::Operator)?), - ]) - } -} - -impl Selector { - fn prefix_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::Operand)?), - ]) - } -} - -impl Selector { - fn function_call_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::Arguments)?), - ]) - } -} - -impl Selector { - fn call_options_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Options)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn member_access_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::Period)?), - Some(self.select(EdgeLabel::Member)?), - ]) - } -} - -impl Selector { - fn index_access_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::OpenBracket)?), - self.try_select(EdgeLabel::Start), - self.try_select(EdgeLabel::End), - Some(self.select(EdgeLabel::CloseBracket)?), - ]) - } -} - -impl Selector { - fn index_access_end_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Colon)?), - self.try_select(EdgeLabel::End), - ]) - } -} - -impl Selector { - fn positional_arguments_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Arguments)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn named_arguments_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - self.try_select(EdgeLabel::Arguments), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn named_argument_group_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Arguments)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn named_argument_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Colon)?), - Some(self.select(EdgeLabel::Value)?), - ]) - } -} - -impl Selector { - fn type_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::TypeKeyword)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::TypeName)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn new_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::NewKeyword)?), - Some(self.select(EdgeLabel::TypeName)?), - ]) - } -} - -impl Selector { - fn tuple_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Items)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn tuple_value_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![self.try_select(EdgeLabel::Expression)]) - } -} - -impl Selector { - fn array_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBracket)?), - Some(self.select(EdgeLabel::Items)?), - Some(self.select(EdgeLabel::CloseBracket)?), - ]) - } -} - -impl Selector { - fn hex_number_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Literal)?), - self.try_select(EdgeLabel::Unit), - ]) - } -} - -impl Selector { - fn decimal_number_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Literal)?), - self.try_select(EdgeLabel::Unit), - ]) - } -} - -impl Selector { - fn yul_block_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBrace)?), - Some(self.select(EdgeLabel::Statements)?), - Some(self.select(EdgeLabel::CloseBrace)?), - ]) - } -} - -impl Selector { - fn yul_function_definition_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::FunctionKeyword)?), - Some(self.select(EdgeLabel::Name)?), - Some(self.select(EdgeLabel::Parameters)?), - self.try_select(EdgeLabel::Returns), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn yul_parameters_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Parameters)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} - -impl Selector { - fn yul_returns_declaration_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::MinusGreaterThan)?), - Some(self.select(EdgeLabel::Variables)?), - ]) - } -} - -impl Selector { - fn yul_variable_declaration_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LetKeyword)?), - Some(self.select(EdgeLabel::Variables)?), - self.try_select(EdgeLabel::Value), - ]) - } -} - -impl Selector { - fn yul_variable_declaration_value_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Assignment)?), - Some(self.select(EdgeLabel::Expression)?), - ]) - } -} - -impl Selector { - fn yul_variable_assignment_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Variables)?), - Some(self.select(EdgeLabel::Assignment)?), - Some(self.select(EdgeLabel::Expression)?), - ]) - } -} - -impl Selector { - fn yul_colon_and_equal_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Colon)?), - Some(self.select(EdgeLabel::Equal)?), - ]) - } -} - -impl Selector { - fn yul_stack_assignment_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Assignment)?), - Some(self.select(EdgeLabel::Variable)?), - ]) - } -} - -impl Selector { - fn yul_equal_and_colon_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Equal)?), - Some(self.select(EdgeLabel::Colon)?), - ]) - } -} - -impl Selector { - fn yul_if_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::IfKeyword)?), - Some(self.select(EdgeLabel::Condition)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn yul_for_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::ForKeyword)?), - Some(self.select(EdgeLabel::Initialization)?), - Some(self.select(EdgeLabel::Condition)?), - Some(self.select(EdgeLabel::Iterator)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn yul_switch_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::SwitchKeyword)?), - Some(self.select(EdgeLabel::Expression)?), - Some(self.select(EdgeLabel::Cases)?), - ]) - } -} - -impl Selector { - fn yul_default_case_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::DefaultKeyword)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn yul_value_case_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::CaseKeyword)?), - Some(self.select(EdgeLabel::Value)?), - Some(self.select(EdgeLabel::Body)?), - ]) - } -} - -impl Selector { - fn yul_leave_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![Some(self.select(EdgeLabel::LeaveKeyword)?)]) - } -} - -impl Selector { - fn yul_break_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![Some(self.select(EdgeLabel::BreakKeyword)?)]) - } -} - -impl Selector { - fn yul_continue_statement_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![Some(self.select(EdgeLabel::ContinueKeyword)?)]) - } -} - -impl Selector { - fn yul_label_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Label)?), - Some(self.select(EdgeLabel::Colon)?), - ]) - } -} - -impl Selector { - fn yul_function_call_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::OpenParen)?), - Some(self.select(EdgeLabel::Arguments)?), - Some(self.select(EdgeLabel::CloseParen)?), - ]) - } -} -// -// Choices: -// - -#[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] -pub fn select_choice( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result> { - let mut selector = Selector::new(node); - - let variant = selector.select(EdgeLabel::Variant)?; - - selector.finalize()?; - Ok(variant) -} - -// -// Repeated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>> { - let mut selector = Selector::new(node); - - let mut items = vec![]; - - while let Some(item) = selector.try_select(EdgeLabel::Item) { - items.push(item); - } - - selector.finalize()?; - Ok(items) -} - -// -// Separated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "[Array, Array]", - catch_unwind -)] -pub fn select_separated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - let mut selector = Selector::new(node); - - let mut items = vec![]; - let mut separators = vec![]; - - if let Some(first) = selector.try_select(EdgeLabel::Item) { - items.push(first); - - while let Some(separator) = selector.try_select(EdgeLabel::Separator) { - separators.push(separator); - - items.push(selector.select(EdgeLabel::Item)?); - } - } - - selector.finalize()?; - Ok(vec![items, separators]) -} - -// -// Common: -// - -struct Selector { - node: Rc, - index: usize, -} - -impl Selector { - fn new(node: &NonterminalNode) -> Self { - Self { - node: Rc::clone(&node.0), - index: 0, - } - } - - fn select(&mut self, target_label: EdgeLabel) -> Result> { - match self.try_select(target_label) { - Some(node) => Ok(node), - None => Error::MissingChild(target_label).into(), - } - } - - fn try_select( - &mut self, - target_label: EdgeLabel, - ) -> Option> { - let (label, node) = self.current()?; - - if label == target_label { - self.index += 1; - Some(node.clone().into_js_either_node()) - } else { - None - } - } - - fn current(&mut self) -> Option<(EdgeLabel, RustNode)> { - loop { - let RustEdge { label, node } = self.node.children.get(self.index)?; - - match label { - // Skip unlabeled nodes: - | None - // Skip trivia: - | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { - self.index += 1; - continue; - } - // Otherwise, return the edge: - Some(other_label) => { - return Some((*other_label, node.clone())); - } - } - } - } - - fn finalize(mut self) -> Result<()> { - match self.current() { - Some((label, _)) => Error::UnrecognizedChild(label).into(), - _ => Ok(()), - } - } -} - -type Result = std::result::Result; - -#[derive(Debug, thiserror::Error)] -enum Error { - // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with NonterminalKind '{0}'.")] - UnexpectedParent(NonterminalKind), - - #[error("Unrecognized child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - UnrecognizedChild(EdgeLabel), - - #[error("Missing child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - MissingChild(EdgeLabel), -} - -impl From for Result { - fn from(error: Error) -> Self { - Err(napi::Error::from_reason(error.to_string())) - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs deleted file mode 100644 index 681bf04f2a..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -pub mod cst; -pub mod diagnostic; -pub mod parser; - -#[path = "generated/ast_selectors.rs"] -pub mod ast_selectors; - -type RustCursor = crate::cst::Cursor; -type RustEdge = crate::cst::Edge; -type RustNode = crate::cst::Node; -type RustParseError = crate::parser::ParseError; -type RustParseOutput = crate::parser::ParseOutput; -type RustQuery = crate::cst::Query; -type RustQueryMatch = crate::cst::QueryMatch; -type RustQueryMatchIterator = crate::cst::QueryMatchIterator; -type RustNonterminalNode = crate::cst::NonterminalNode; -type RustTextIndex = crate::cst::TextIndex; -type RustTextRange = crate::cst::TextRange; -type RustTerminalNode = crate::cst::TerminalNode; - -type NonterminalKind = crate::cst::NonterminalKind; -type TerminalKind = crate::cst::TerminalKind; -type EdgeLabel = crate::cst::EdgeLabel; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/mod.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/mod.rs deleted file mode 100644 index 0623fb565d..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -mod parse_error; -mod parse_output; - -pub use parse_error::ParseError; -pub use parse_output::ParseOutput; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_error.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_error.rs deleted file mode 100644 index a7f67442e9..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_error.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// NAPI-exposed functions have to accept owned values. -#![allow(clippy::needless_pass_by_value)] - -use napi_derive::napi; - -use crate::expose_diagnostic_trait_interface; -use crate::napi_interface::RustParseError; - -#[napi(namespace = "parser")] -#[derive(PartialEq, Clone)] -pub struct ParseError(RustParseError); - -impl From for ParseError { - fn from(value: RustParseError) -> Self { - Self(value) - } -} - -expose_diagnostic_trait_interface!("parser", ParseError); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_output.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_output.rs deleted file mode 100644 index 455c2ac8ea..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/parser/parse_output.rs +++ /dev/null @@ -1,41 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{Cursor, NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::parser::ParseError; -use crate::napi_interface::RustParseOutput; - -#[napi(namespace = "parser")] -pub struct ParseOutput(RustParseOutput); - -impl From for ParseOutput { - fn from(value: RustParseOutput) -> Self { - Self(value) - } -} - -#[napi(namespace = "parser")] -impl ParseOutput { - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { - self.0.tree().into_js_either_node() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn errors(&self) -> Vec { - self.0.errors().iter().map(|x| x.clone().into()).collect() - } - - #[napi(getter, catch_unwind)] - pub fn is_valid(&self) -> bool { - self.0.is_valid() - } - - /// Creates a cursor that starts at the root of the parse tree. - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_tree_cursor(&self) -> Cursor { - self.0.create_tree_cursor().into() - } -} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_types.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_types.rs deleted file mode 100644 index 70d68c5abc..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_types.rs +++ /dev/null @@ -1,8 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. -// You can use 'cargo expand' to see its output, or run the CLI version directly of 'wit-bindgen' via: -// -// wit-bindgen rust "./generated" --pub-export-macro --out-dir "./target/wit/" - -wit_bindgen::generate!(in "src/generated/wit/interface/generated"); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/diagnostic.wit b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/diagnostic.wit deleted file mode 100644 index 000fcaf719..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/diagnostic.wit +++ /dev/null @@ -1,10 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -interface diagnostic { - enum severity { - error, - warning, - information, - hint, - } -} 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 deleted file mode 100644 index 900317ef19..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#[path = "./interface/generated/_types.rs"] -mod interface; -mod utils; -mod wrappers; - -struct World; - -crate::wit::interface::export!(World with_types_in crate::wit::interface); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/diagnostic.rs b/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/diagnostic.rs deleted file mode 100644 index 51af0b9885..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/diagnostic.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use crate::wit::utils::enum_to_enum; - -mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; -} - -mod rust { - pub use crate::diagnostic::Severity; -} - -//================================================ -// -// enum severity -// -//================================================ - -enum_to_enum!(Severity); diff --git a/crates/solidity/outputs/cargo/slang_solidity_cli/src/main.rs b/crates/solidity/outputs/cargo/slang_solidity_cli/src/main.rs deleted file mode 100644 index d9a8bec513..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity_cli/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - slang_solidity::cli::execute(); -} diff --git a/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml b/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml deleted file mode 100644 index 17ad89a5d3..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity_node_addon/Cargo.toml +++ /dev/null @@ -1,51 +0,0 @@ -[package] -name = "slang_solidity_node_addon" -version.workspace = true -rust-version.workspace = true -edition.workspace = true -publish = false - -description = "slang_solidity compiled as a cdylib crate, to be used as Node.js addon." - -# At the time of writing, building cdylib/plugins with Cargo has limited support -# (see for the general tracking issue). -# To workaround some of the issues, we create a synthetic crate that shares the same code as the original Rust crate -# but only exposes a `cdylib` library. -# There are a couple of things at play here: -# - To build a Node addon, we need to build a standalone cdylib, that's set up to expect host `napi_*` functions at runtime -# - `napi build` does that for us but only supports `cdylib` for the `lib` targets (e.g. not bin/examples) -# - expansion of #[napi] macros is enabled behind a feature flag; it expands the code that expects the host functions -# - while `napi/noop` feature exists that disables that, we test in workspace with `--all-features` and Cargo features are additive -# - thus, they get conflated and so the regular `rlib` library target gets built with the host functions expectation -# - ...which reasonably fails to link when `rlib` library is used as a regular Rust library (i.e. not in Node environment). -# Another workaround is to use an example with `cdylib` crate-type (wouldn't conflate the features in a downstream usable -# library), but napi doesn't support that yet. -# Also see for a similar issue with PyO3. -[lib] -path = "../slang_solidity/src/lib.rs" -crate-type = ["cdylib"] - -# __RUST_NAPI_CRATE_FEATURES__ (keep in sync) -[features] -default = ["__private_napi_interfaces"] -__private_napi_interfaces = [ - # This enables '#[napi]' attributes on the Rust types imported via [lib.path] above. - "dep:serde_json", -] - -[build-dependencies] -napi-build = { workspace = true } - -[dependencies] -metaslang_cst = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } -semver = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true, optional = true } -strum = { workspace = true } -strum_macros = { workspace = true } -thiserror = { workspace = true } - -[lints] -workspace = true diff --git a/crates/solidity/outputs/cargo/slang_solidity_node_addon/build.rs b/crates/solidity/outputs/cargo/slang_solidity_node_addon/build.rs deleted file mode 100644 index bb9898efca..0000000000 --- a/crates/solidity/outputs/cargo/slang_solidity_node_addon/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[cfg(not(feature = "__private_napi_interfaces"))] -compile_error!("The whole point is to enable __private_napi_interfaces for this cdylib crate!"); - -fn main() { - napi_build::setup(); -} diff --git a/crates/solidity/outputs/cargo/tests/Cargo.toml b/crates/solidity/outputs/cargo/tests/Cargo.toml index 839fbf1c52..efa99b67e2 100644 --- a/crates/solidity/outputs/cargo/tests/Cargo.toml +++ b/crates/solidity/outputs/cargo/tests/Cargo.toml @@ -27,6 +27,7 @@ regex = { workspace = true } semver = { workspace = true } slang_solidity = { workspace = true, features = [ "__experimental_bindings_api", + "__private_ariadne_errors", "__private_testing_utils", ] } solidity_language = { workspace = true } diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs index 4862676d73..93f982be82 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_assertions/runner.rs @@ -29,7 +29,7 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> { } fn check_assertions_with_version(version: &Version, contents: &str) -> Result<()> { - let parser = Parser::new(version.clone())?; + let parser = Parser::create(version.clone())?; let mut bindings = bindings::create_with_resolver(version.clone(), Arc::new(TestsPathResolver {})); let mut assertions = Assertions::new(); diff --git a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs index 7fa624f9f2..58027ab1f9 100644 --- a/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/bindings_output/runner.rs @@ -39,7 +39,7 @@ pub fn run(group_name: &str, test_name: &str) -> Result<()> { let mut last_bindings_output = None; for version in &VERSION_BREAKS { - let parser = Parser::new(version.clone())?; + let parser = Parser::create(version.clone())?; let mut bindings = bindings::create_with_resolver(version.clone(), Arc::new(TestsPathResolver {})); let mut parsed_parts: Vec> = Vec::new(); diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs index 768adfebb9..0d986f4bd4 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs @@ -37,7 +37,7 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> { let tested_kind = NonterminalKind::from_str(parser_name) .unwrap_or_else(|_| panic!("No such parser: {parser_name}")); - let output = Parser::new(version.clone())?.parse(tested_kind, &source); + let output = Parser::create(version.clone())?.parse(tested_kind, &source); let output = match last_output { // Skip this version if it produces the same output. diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs index e03fda8840..07498aa90e 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/tree_query_language.rs @@ -19,7 +19,7 @@ impl RemoveMkdocSnippetMarkers for &str { } fn assert_matches(query: &Query, kind: NonterminalKind, source: &str) -> QueryMatchIterator { - let parser = Parser::new(Version::new(0, 8, 12)).unwrap(); + let parser = Parser::create(Version::new(0, 8, 12)).unwrap(); let cursor = parser.parse(kind, source).create_tree_cursor(); let tree = cursor.node(); diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs index bed1a9c18c..9273eb664b 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_queries.rs @@ -11,7 +11,7 @@ fn parse_doc_input_file>(path: T) -> Result { let source = input_path.read_to_string()?; - let parser = Parser::new(Version::new(0, 8, 0))?; + let parser = Parser::create(Version::new(0, 8, 0))?; Ok(parser.parse(NonterminalKind::SourceUnit, source.trim())) } diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs index f7a8a3a57f..ce9790062b 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_cursor.rs @@ -1,5 +1,4 @@ use std::path::Path; -use std::rc::Rc; use anyhow::Result; use infra_utils::paths::PathExtensions; @@ -19,7 +18,7 @@ fn using_the_cursor() -> Result<()> { let source = source.trim(); // --8<-- [start:parse-input] - let parser = Parser::new(Version::parse("0.8.0")?)?; + let parser = Parser::create(Version::parse("0.8.0")?)?; let parse_output = parser.parse(NonterminalKind::SourceUnit, source); // --8<-- [end:parse-input] @@ -71,7 +70,7 @@ fn using_the_cursor() -> Result<()> { while cursor.go_to_next_nonterminal_with_kind(NonterminalKind::ContractDefinition) { let range = cursor.text_range().utf8(); - let text = Rc::clone(cursor.node().as_nonterminal().unwrap()).unparse(); + let text = cursor.node().unparse(); contracts.push((range, text.trim().to_owned())); } diff --git a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs index 32133271b5..69fb289bcb 100644 --- a/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs +++ b/crates/solidity/outputs/cargo/tests/src/doc_examples/using_the_parser.rs @@ -1,5 +1,4 @@ use std::path::Path; -use std::rc::Rc; use anyhow::Result; use infra_utils::paths::PathExtensions; @@ -19,7 +18,7 @@ fn using_the_parser() -> Result<()> { let source = source.trim(); // --8<-- [start:parse-input] - let parser = Parser::new(Version::parse("0.8.0")?)?; + let parser = Parser::create(Version::parse("0.8.0")?)?; let parse_output = parser.parse(NonterminalKind::ContractDefinition, source); // --8<-- [end:parse-input] @@ -60,8 +59,7 @@ fn using_the_parser() -> Result<()> { // --8<-- [end:inspect-tree] // --8<-- [start:unparse-node] - let contract_source = Rc::clone(contract).unparse(); - assert_eq!(contract_source, "contract Foo {}"); + assert_eq!(contract.unparse(), "contract Foo {}"); // --8<-- [end:unparse-node] Ok(()) diff --git a/crates/solidity/outputs/cargo/tests/src/trivia.rs b/crates/solidity/outputs/cargo/tests/src/trivia.rs index c1dae14bf2..febb959fb5 100644 --- a/crates/solidity/outputs/cargo/tests/src/trivia.rs +++ b/crates/solidity/outputs/cargo/tests/src/trivia.rs @@ -22,7 +22,7 @@ fn end_of_line() -> Result<()> { fn compare_end_of_lines(input: &str, expected: &[&str]) -> Result<()> { let version = Version::parse("0.8.0")?; - let parser = Parser::new(version)?; + let parser = Parser::create(version)?; let output = parser.parse(NonterminalKind::SourceUnit, input); assert!(output.is_valid()); diff --git a/crates/solidity/outputs/cargo/wasm/Cargo.toml b/crates/solidity/outputs/cargo/wasm/Cargo.toml new file mode 100644 index 0000000000..d4a6399e87 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "solidity_cargo_wasm" +version.workspace = true +rust-version.workspace = true +edition.workspace = true +publish = false + +# At the time of writing, building 'cdylib' plugins with Cargo has limited support +# (see for the general tracking issue). +# To workaround some of the issues, we create a separate 'cdylib' crate that defines the WASM wrappers. +[lib] +crate-type = ["cdylib"] + +[build-dependencies] +anyhow = { workspace = true } +codegen_runtime_generator = { workspace = true } +infra_utils = { workspace = true } +solidity_language = { workspace = true } + +[dependencies] +paste = { workspace = true } +semver = { workspace = true } +serde_json = { workspace = true } +slang_solidity = { workspace = true } +wit-bindgen = { workspace = true } + +[lints] +workspace = true diff --git a/crates/solidity/outputs/cargo/wasm/build.rs b/crates/solidity/outputs/cargo/wasm/build.rs new file mode 100644 index 0000000000..afd4c936e8 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/build.rs @@ -0,0 +1,16 @@ +use anyhow::Result; +use codegen_runtime_generator::RuntimeGenerator; +use infra_utils::cargo::CargoWorkspace; +use solidity_language::SolidityDefinition; + +fn main() -> Result<()> { + let language = SolidityDefinition::create(); + + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_cargo_wasm")?.join("src/runtime"); + + let output_dir = + CargoWorkspace::locate_source_crate("solidity_cargo_wasm")?.join("src/generated"); + + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) +} diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/generated/bindings.rs b/crates/solidity/outputs/cargo/wasm/src/generated/generated/bindings.rs new file mode 100644 index 0000000000..db8654633f --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/generated/bindings.rs @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. +// You can use 'cargo expand' to see its output, or run the 'wit-bindgen rust' command. + +wit_bindgen::generate!(in "src/generated/interface/generated"); diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/generated/config.json b/crates/solidity/outputs/cargo/wasm/src/generated/generated/config.json new file mode 100644 index 0000000000..f642396029 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/generated/config.json @@ -0,0 +1,139 @@ +{ + "mappings": { + "nomic-foundation:slang:cst:terminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:nonterminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:edge-label": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:node": { + "Variant": { + "as_direct_union_of_resource_classes": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:terminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.node()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.label()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-offset()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.depth()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.ancestors()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:query-match.captures": { + "ListOfTuple": { + "as_dictionary": true + } + }, + "nomic-foundation:slang:cst:query-match-iterator": { + "Resource": { + "as_iterator": true + } + }, + "nomic-foundation:slang:parser:parser.version()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.message()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.tree()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.errors()": { + "Function": { + "as_getter": true + } + } + } +} diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/ast.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/ast.wit new file mode 100644 index 0000000000..31c6a91f88 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/ast.wit @@ -0,0 +1,12 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface ast { + use cst.{node, nonterminal-node}; + + resource selectors { + sequence: static func(node: nonterminal-node) -> result>, string>; + choice: static func(node: nonterminal-node) -> result; + repeated: static func(node: nonterminal-node) -> result, string>; + separated: static func(node: nonterminal-node) -> result>, string>; + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/cst.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/cst.wit similarity index 97% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/cst.wit rename to crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/cst.wit index dcb542ad90..ab8ba241c6 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/cst.wit +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/cst.wit @@ -222,147 +222,10 @@ interface cst { %yul-variable-names, } - 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, - %minus-greater-than, - %modifier-keyword, - %name, - %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, - %variable-type, - %variables, - %version, - %while-keyword, - } - enum terminal-kind { // Built-in: - skipped, + unrecognized, + missing, // Generated: %abicoder-keyword, @@ -736,23 +599,179 @@ interface cst { %yul-years-keyword, } + resource terminal-kind-extensions { + is-trivia: static func(kind: terminal-kind) -> bool; + is-valid: static func(kind: terminal-kind) -> bool; + } + + 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, + %minus-greater-than, + %modifier-keyword, + %name, + %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, + %variable-type, + %variables, + %version, + %while-keyword, + } + variant node { nonterminal(nonterminal-node), terminal(terminal-node) } resource nonterminal-node { + id: func() -> u32; kind: func() -> nonterminal-kind; - text-len: func() -> text-index; - children: func() -> list; - create-cursor: func(text-offset: text-index) -> cursor; + text-length: func() -> text-index; + + children: func() -> list; unparse: func() -> string; + to-json: func() -> string; + + create-cursor: func(text-offset: text-index) -> cursor; } resource terminal-node { + id: func() -> u32; kind: func() -> terminal-kind; - text-len: func() -> text-index; - text: func() -> string; + text-length: func() -> text-index; + + children: func() -> list; + unparse: func() -> string; + to-json: func() -> string; + } + + record edge { + label: option, + node: node, } resource cursor { @@ -803,7 +822,7 @@ interface cst { record query-error { message: string, - row: u32, + line: u32, column: u32, } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/parser.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/parser.wit similarity index 83% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/parser.wit rename to crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/parser.wit index 8381cb836d..f5ae55423e 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/parser.wit +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/parser.wit @@ -2,17 +2,17 @@ interface parser { use cst.{cursor, node, nonterminal-kind, text-range}; - use diagnostic.{severity}; resource parser { + root-kind: static func() -> nonterminal-kind; supported-versions: static func() -> list; - new: static func(version: string) -> result; + create: static func(version: string) -> result; + version: func() -> string; parse: func(kind: nonterminal-kind, input: string) -> parse-output; } resource parse-error { - severity: func() -> severity; text-range: func() -> text-range; message: func() -> string; } diff --git a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_world.wit b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit similarity index 88% rename from crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_world.wit rename to crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit index 7f826767f4..c5e1378860 100644 --- a/crates/codegen/runtime/cargo/src/runtime/wit/interface/generated/_world.wit +++ b/crates/solidity/outputs/cargo/wasm/src/generated/interface/generated/world.wit @@ -3,7 +3,7 @@ package nomic-foundation:slang; world slang { + export ast; export cst; - export diagnostic; export parser; } diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/mod.rs b/crates/solidity/outputs/cargo/wasm/src/generated/mod.rs new file mode 100644 index 0000000000..c84d868d87 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/mod.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[path = "./generated/bindings.rs"] +mod bindings; +mod utils; +mod wrappers; + +struct World; + +crate::wasm_crate::bindings::export!(World with_types_in crate::wasm_crate::bindings); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/utils.rs b/crates/solidity/outputs/cargo/wasm/src/generated/utils.rs similarity index 88% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/utils.rs rename to crates/solidity/outputs/cargo/wasm/src/generated/utils.rs index df09032699..fb8549efea 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/utils.rs +++ b/crates/solidity/outputs/cargo/wasm/src/generated/utils.rs @@ -14,14 +14,14 @@ macro_rules! define_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (rust::$name); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0 @@ -63,14 +63,14 @@ macro_rules! define_rc_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::rc::Rc); - impl $crate::wit::utils::IntoFFI for std::rc::Rc { + impl $crate::wasm_crate::utils::IntoFFI for std::rc::Rc { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI> for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI> for ffi::$name { #[inline] fn _from_ffi(self) -> std::rc::Rc { self.into_inner::<[<$name Wrapper>]>().0 @@ -112,14 +112,14 @@ macro_rules! define_refcell_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::cell::RefCell); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0.into_inner() @@ -169,14 +169,14 @@ macro_rules! define_refcell_wrapper { macro_rules! enum_to_enum { ($name:ident) => { - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { unsafe { core::mem::transmute(self) } } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { unsafe { core::mem::transmute(self) } diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs new file mode 100644 index 0000000000..496bdb4c04 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs @@ -0,0 +1,1632 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#![allow(clippy::too_many_lines)] // large match statements for all non-terminals +#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling + +use std::rc::Rc; + +use crate::rust_crate::cst::{Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode}; + +// +// Sequences: +// + +pub fn select_sequence(node: &Rc) -> Result>> { + let mut helper = Helper::new(node); + + let result = match node.kind { + NonterminalKind::SourceUnit => helper.source_unit_sequence()?, + NonterminalKind::PragmaDirective => helper.pragma_directive_sequence()?, + NonterminalKind::AbicoderPragma => helper.abicoder_pragma_sequence()?, + NonterminalKind::ExperimentalPragma => helper.experimental_pragma_sequence()?, + NonterminalKind::VersionPragma => helper.version_pragma_sequence()?, + NonterminalKind::VersionRange => helper.version_range_sequence()?, + NonterminalKind::VersionTerm => helper.version_term_sequence()?, + NonterminalKind::ImportDirective => helper.import_directive_sequence()?, + NonterminalKind::PathImport => helper.path_import_sequence()?, + NonterminalKind::NamedImport => helper.named_import_sequence()?, + NonterminalKind::ImportDeconstruction => helper.import_deconstruction_sequence()?, + NonterminalKind::ImportDeconstructionSymbol => { + helper.import_deconstruction_symbol_sequence()? + } + NonterminalKind::ImportAlias => helper.import_alias_sequence()?, + NonterminalKind::UsingDirective => helper.using_directive_sequence()?, + NonterminalKind::UsingDeconstruction => helper.using_deconstruction_sequence()?, + NonterminalKind::UsingDeconstructionSymbol => { + helper.using_deconstruction_symbol_sequence()? + } + NonterminalKind::UsingAlias => helper.using_alias_sequence()?, + NonterminalKind::ContractDefinition => helper.contract_definition_sequence()?, + NonterminalKind::InheritanceSpecifier => helper.inheritance_specifier_sequence()?, + NonterminalKind::InheritanceType => helper.inheritance_type_sequence()?, + NonterminalKind::InterfaceDefinition => helper.interface_definition_sequence()?, + NonterminalKind::LibraryDefinition => helper.library_definition_sequence()?, + NonterminalKind::StructDefinition => helper.struct_definition_sequence()?, + NonterminalKind::StructMember => helper.struct_member_sequence()?, + NonterminalKind::EnumDefinition => helper.enum_definition_sequence()?, + NonterminalKind::ConstantDefinition => helper.constant_definition_sequence()?, + NonterminalKind::StateVariableDefinition => helper.state_variable_definition_sequence()?, + NonterminalKind::StateVariableDefinitionValue => { + helper.state_variable_definition_value_sequence()? + } + NonterminalKind::FunctionDefinition => helper.function_definition_sequence()?, + NonterminalKind::ParametersDeclaration => helper.parameters_declaration_sequence()?, + NonterminalKind::Parameter => helper.parameter_sequence()?, + NonterminalKind::OverrideSpecifier => helper.override_specifier_sequence()?, + NonterminalKind::OverridePathsDeclaration => { + helper.override_paths_declaration_sequence()? + } + NonterminalKind::ReturnsDeclaration => helper.returns_declaration_sequence()?, + NonterminalKind::ConstructorDefinition => helper.constructor_definition_sequence()?, + NonterminalKind::UnnamedFunctionDefinition => { + helper.unnamed_function_definition_sequence()? + } + NonterminalKind::FallbackFunctionDefinition => { + helper.fallback_function_definition_sequence()? + } + NonterminalKind::ReceiveFunctionDefinition => { + helper.receive_function_definition_sequence()? + } + NonterminalKind::ModifierDefinition => helper.modifier_definition_sequence()?, + NonterminalKind::ModifierInvocation => helper.modifier_invocation_sequence()?, + NonterminalKind::EventDefinition => helper.event_definition_sequence()?, + NonterminalKind::EventParametersDeclaration => { + helper.event_parameters_declaration_sequence()? + } + NonterminalKind::EventParameter => helper.event_parameter_sequence()?, + NonterminalKind::UserDefinedValueTypeDefinition => { + helper.user_defined_value_type_definition_sequence()? + } + NonterminalKind::ErrorDefinition => helper.error_definition_sequence()?, + NonterminalKind::ErrorParametersDeclaration => { + helper.error_parameters_declaration_sequence()? + } + NonterminalKind::ErrorParameter => helper.error_parameter_sequence()?, + NonterminalKind::ArrayTypeName => helper.array_type_name_sequence()?, + NonterminalKind::FunctionType => helper.function_type_sequence()?, + NonterminalKind::MappingType => helper.mapping_type_sequence()?, + NonterminalKind::MappingKey => helper.mapping_key_sequence()?, + NonterminalKind::MappingValue => helper.mapping_value_sequence()?, + NonterminalKind::AddressType => helper.address_type_sequence()?, + NonterminalKind::Block => helper.block_sequence()?, + NonterminalKind::UncheckedBlock => helper.unchecked_block_sequence()?, + NonterminalKind::ExpressionStatement => helper.expression_statement_sequence()?, + NonterminalKind::AssemblyStatement => helper.assembly_statement_sequence()?, + NonterminalKind::AssemblyFlagsDeclaration => { + helper.assembly_flags_declaration_sequence()? + } + NonterminalKind::TupleDeconstructionStatement => { + helper.tuple_deconstruction_statement_sequence()? + } + NonterminalKind::TupleDeconstructionElement => { + helper.tuple_deconstruction_element_sequence()? + } + NonterminalKind::TypedTupleMember => helper.typed_tuple_member_sequence()?, + NonterminalKind::UntypedTupleMember => helper.untyped_tuple_member_sequence()?, + NonterminalKind::VariableDeclarationStatement => { + helper.variable_declaration_statement_sequence()? + } + NonterminalKind::VariableDeclarationValue => { + helper.variable_declaration_value_sequence()? + } + NonterminalKind::IfStatement => helper.if_statement_sequence()?, + NonterminalKind::ElseBranch => helper.else_branch_sequence()?, + NonterminalKind::ForStatement => helper.for_statement_sequence()?, + NonterminalKind::WhileStatement => helper.while_statement_sequence()?, + NonterminalKind::DoWhileStatement => helper.do_while_statement_sequence()?, + NonterminalKind::ContinueStatement => helper.continue_statement_sequence()?, + NonterminalKind::BreakStatement => helper.break_statement_sequence()?, + NonterminalKind::ReturnStatement => helper.return_statement_sequence()?, + NonterminalKind::EmitStatement => helper.emit_statement_sequence()?, + NonterminalKind::TryStatement => helper.try_statement_sequence()?, + NonterminalKind::CatchClause => helper.catch_clause_sequence()?, + NonterminalKind::CatchClauseError => helper.catch_clause_error_sequence()?, + NonterminalKind::RevertStatement => helper.revert_statement_sequence()?, + NonterminalKind::ThrowStatement => helper.throw_statement_sequence()?, + NonterminalKind::AssignmentExpression => helper.assignment_expression_sequence()?, + NonterminalKind::ConditionalExpression => helper.conditional_expression_sequence()?, + NonterminalKind::OrExpression => helper.or_expression_sequence()?, + NonterminalKind::AndExpression => helper.and_expression_sequence()?, + NonterminalKind::EqualityExpression => helper.equality_expression_sequence()?, + NonterminalKind::ComparisonExpression => helper.comparison_expression_sequence()?, + NonterminalKind::BitwiseOrExpression => helper.bitwise_or_expression_sequence()?, + NonterminalKind::BitwiseXorExpression => helper.bitwise_xor_expression_sequence()?, + NonterminalKind::BitwiseAndExpression => helper.bitwise_and_expression_sequence()?, + NonterminalKind::ShiftExpression => helper.shift_expression_sequence()?, + NonterminalKind::AdditiveExpression => helper.additive_expression_sequence()?, + NonterminalKind::MultiplicativeExpression => helper.multiplicative_expression_sequence()?, + NonterminalKind::ExponentiationExpression => helper.exponentiation_expression_sequence()?, + NonterminalKind::PostfixExpression => helper.postfix_expression_sequence()?, + NonterminalKind::PrefixExpression => helper.prefix_expression_sequence()?, + NonterminalKind::FunctionCallExpression => helper.function_call_expression_sequence()?, + NonterminalKind::CallOptionsExpression => helper.call_options_expression_sequence()?, + NonterminalKind::MemberAccessExpression => helper.member_access_expression_sequence()?, + NonterminalKind::IndexAccessExpression => helper.index_access_expression_sequence()?, + NonterminalKind::IndexAccessEnd => helper.index_access_end_sequence()?, + NonterminalKind::PositionalArgumentsDeclaration => { + helper.positional_arguments_declaration_sequence()? + } + NonterminalKind::NamedArgumentsDeclaration => { + helper.named_arguments_declaration_sequence()? + } + NonterminalKind::NamedArgumentGroup => helper.named_argument_group_sequence()?, + NonterminalKind::NamedArgument => helper.named_argument_sequence()?, + NonterminalKind::TypeExpression => helper.type_expression_sequence()?, + NonterminalKind::NewExpression => helper.new_expression_sequence()?, + NonterminalKind::TupleExpression => helper.tuple_expression_sequence()?, + NonterminalKind::TupleValue => helper.tuple_value_sequence()?, + NonterminalKind::ArrayExpression => helper.array_expression_sequence()?, + NonterminalKind::HexNumberExpression => helper.hex_number_expression_sequence()?, + NonterminalKind::DecimalNumberExpression => helper.decimal_number_expression_sequence()?, + NonterminalKind::YulBlock => helper.yul_block_sequence()?, + NonterminalKind::YulFunctionDefinition => helper.yul_function_definition_sequence()?, + NonterminalKind::YulParametersDeclaration => { + helper.yul_parameters_declaration_sequence()? + } + NonterminalKind::YulReturnsDeclaration => helper.yul_returns_declaration_sequence()?, + NonterminalKind::YulVariableDeclarationStatement => { + helper.yul_variable_declaration_statement_sequence()? + } + NonterminalKind::YulVariableDeclarationValue => { + helper.yul_variable_declaration_value_sequence()? + } + NonterminalKind::YulVariableAssignmentStatement => { + helper.yul_variable_assignment_statement_sequence()? + } + NonterminalKind::YulColonAndEqual => helper.yul_colon_and_equal_sequence()?, + NonterminalKind::YulStackAssignmentStatement => { + helper.yul_stack_assignment_statement_sequence()? + } + NonterminalKind::YulEqualAndColon => helper.yul_equal_and_colon_sequence()?, + NonterminalKind::YulIfStatement => helper.yul_if_statement_sequence()?, + NonterminalKind::YulForStatement => helper.yul_for_statement_sequence()?, + NonterminalKind::YulSwitchStatement => helper.yul_switch_statement_sequence()?, + NonterminalKind::YulDefaultCase => helper.yul_default_case_sequence()?, + NonterminalKind::YulValueCase => helper.yul_value_case_sequence()?, + NonterminalKind::YulLeaveStatement => helper.yul_leave_statement_sequence()?, + NonterminalKind::YulBreakStatement => helper.yul_break_statement_sequence()?, + NonterminalKind::YulContinueStatement => helper.yul_continue_statement_sequence()?, + NonterminalKind::YulLabel => helper.yul_label_sequence()?, + NonterminalKind::YulFunctionCallExpression => { + helper.yul_function_call_expression_sequence()? + } + _ => { + // Should not theoretically happen, since we're only called from our own generated AST types. + return Err(format!( + "Unexpected parent node with NonterminalKind '{0}'.", + node.kind + )); + } + }; + + helper.finalize()?; + Ok(result) +} +impl Helper { + fn source_unit_sequence(&mut self) -> Result>> { + Ok(vec![Some(self.select(EdgeLabel::Members)?)]) + } +} + +impl Helper { + fn pragma_directive_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::PragmaKeyword)?), + Some(self.select(EdgeLabel::Pragma)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn abicoder_pragma_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::AbicoderKeyword)?), + Some(self.select(EdgeLabel::Version)?), + ]) + } +} + +impl Helper { + fn experimental_pragma_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ExperimentalKeyword)?), + Some(self.select(EdgeLabel::Feature)?), + ]) + } +} + +impl Helper { + fn version_pragma_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::SolidityKeyword)?), + Some(self.select(EdgeLabel::Sets)?), + ]) + } +} + +impl Helper { + fn version_range_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Start)?), + Some(self.select(EdgeLabel::Minus)?), + Some(self.select(EdgeLabel::End)?), + ]) + } +} + +impl Helper { + fn version_term_sequence(&mut self) -> Result>> { + Ok(vec![ + self.try_select(EdgeLabel::Operator), + Some(self.select(EdgeLabel::Literal)?), + ]) + } +} + +impl Helper { + fn import_directive_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ImportKeyword)?), + Some(self.select(EdgeLabel::Clause)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn path_import_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Path)?), + self.try_select(EdgeLabel::Alias), + ]) + } +} + +impl Helper { + fn named_import_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Asterisk)?), + Some(self.select(EdgeLabel::Alias)?), + Some(self.select(EdgeLabel::FromKeyword)?), + Some(self.select(EdgeLabel::Path)?), + ]) + } +} + +impl Helper { + fn import_deconstruction_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Symbols)?), + Some(self.select(EdgeLabel::CloseBrace)?), + Some(self.select(EdgeLabel::FromKeyword)?), + Some(self.select(EdgeLabel::Path)?), + ]) + } +} + +impl Helper { + fn import_deconstruction_symbol_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Alias), + ]) + } +} + +impl Helper { + fn import_alias_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::AsKeyword)?), + Some(self.select(EdgeLabel::Identifier)?), + ]) + } +} + +impl Helper { + fn using_directive_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::UsingKeyword)?), + Some(self.select(EdgeLabel::Clause)?), + Some(self.select(EdgeLabel::ForKeyword)?), + Some(self.select(EdgeLabel::Target)?), + self.try_select(EdgeLabel::GlobalKeyword), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn using_deconstruction_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Symbols)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn using_deconstruction_symbol_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Alias), + ]) + } +} + +impl Helper { + fn using_alias_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::AsKeyword)?), + Some(self.select(EdgeLabel::Operator)?), + ]) + } +} + +impl Helper { + fn contract_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + self.try_select(EdgeLabel::AbstractKeyword), + Some(self.select(EdgeLabel::ContractKeyword)?), + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Inheritance), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn inheritance_specifier_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::IsKeyword)?), + Some(self.select(EdgeLabel::Types)?), + ]) + } +} + +impl Helper { + fn inheritance_type_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::Arguments), + ]) + } +} + +impl Helper { + fn interface_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::InterfaceKeyword)?), + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Inheritance), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn library_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LibraryKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn struct_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::StructKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn struct_member_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn enum_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::EnumKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn constant_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + Some(self.select(EdgeLabel::ConstantKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Equal)?), + Some(self.select(EdgeLabel::Value)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn state_variable_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + Some(self.select(EdgeLabel::Attributes)?), + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Value), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn state_variable_definition_value_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Equal)?), + Some(self.select(EdgeLabel::Value)?), + ]) + } +} + +impl Helper { + fn function_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::FunctionKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + self.try_select(EdgeLabel::Returns), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn parameters_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn parameter_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::StorageLocation), + self.try_select(EdgeLabel::Name), + ]) + } +} + +impl Helper { + fn override_specifier_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OverrideKeyword)?), + self.try_select(EdgeLabel::Overridden), + ]) + } +} + +impl Helper { + fn override_paths_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Paths)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn returns_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ReturnsKeyword)?), + Some(self.select(EdgeLabel::Variables)?), + ]) + } +} + +impl Helper { + fn constructor_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ConstructorKeyword)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn unnamed_function_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::FunctionKeyword)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn fallback_function_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::FallbackKeyword)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + self.try_select(EdgeLabel::Returns), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn receive_function_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ReceiveKeyword)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn modifier_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ModifierKeyword)?), + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Parameters), + Some(self.select(EdgeLabel::Attributes)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn modifier_invocation_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Arguments), + ]) + } +} + +impl Helper { + fn event_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::EventKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Parameters)?), + self.try_select(EdgeLabel::AnonymousKeyword), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn event_parameters_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn event_parameter_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::IndexedKeyword), + self.try_select(EdgeLabel::Name), + ]) + } +} + +impl Helper { + fn user_defined_value_type_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::IsKeyword)?), + Some(self.select(EdgeLabel::ValueType)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn error_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ErrorKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn error_parameters_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn error_parameter_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::Name), + ]) + } +} + +impl Helper { + fn array_type_name_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::OpenBracket)?), + self.try_select(EdgeLabel::Index), + Some(self.select(EdgeLabel::CloseBracket)?), + ]) + } +} + +impl Helper { + fn function_type_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::FunctionKeyword)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::Attributes)?), + self.try_select(EdgeLabel::Returns), + ]) + } +} + +impl Helper { + fn mapping_type_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::MappingKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::KeyType)?), + Some(self.select(EdgeLabel::EqualGreaterThan)?), + Some(self.select(EdgeLabel::ValueType)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn mapping_key_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::KeyType)?), + self.try_select(EdgeLabel::Name), + ]) + } +} + +impl Helper { + fn mapping_value_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::Name), + ]) + } +} + +impl Helper { + fn address_type_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::AddressKeyword)?), + self.try_select(EdgeLabel::PayableKeyword), + ]) + } +} + +impl Helper { + fn block_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Statements)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn unchecked_block_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::UncheckedKeyword)?), + Some(self.select(EdgeLabel::Block)?), + ]) + } +} + +impl Helper { + fn expression_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Expression)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn assembly_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::AssemblyKeyword)?), + self.try_select(EdgeLabel::Label), + self.try_select(EdgeLabel::Flags), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn assembly_flags_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Flags)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn tuple_deconstruction_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + self.try_select(EdgeLabel::VarKeyword), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Elements)?), + Some(self.select(EdgeLabel::CloseParen)?), + Some(self.select(EdgeLabel::Equal)?), + Some(self.select(EdgeLabel::Expression)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn tuple_deconstruction_element_sequence(&mut self) -> Result>> { + Ok(vec![self.try_select(EdgeLabel::Member)]) + } +} + +impl Helper { + fn typed_tuple_member_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeName)?), + self.try_select(EdgeLabel::StorageLocation), + Some(self.select(EdgeLabel::Name)?), + ]) + } +} + +impl Helper { + fn untyped_tuple_member_sequence(&mut self) -> Result>> { + Ok(vec![ + self.try_select(EdgeLabel::StorageLocation), + Some(self.select(EdgeLabel::Name)?), + ]) + } +} + +impl Helper { + fn variable_declaration_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::VariableType)?), + self.try_select(EdgeLabel::StorageLocation), + Some(self.select(EdgeLabel::Name)?), + self.try_select(EdgeLabel::Value), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn variable_declaration_value_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Equal)?), + Some(self.select(EdgeLabel::Expression)?), + ]) + } +} + +impl Helper { + fn if_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::IfKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Condition)?), + Some(self.select(EdgeLabel::CloseParen)?), + Some(self.select(EdgeLabel::Body)?), + self.try_select(EdgeLabel::ElseBranch), + ]) + } +} + +impl Helper { + fn else_branch_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ElseKeyword)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn for_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ForKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Initialization)?), + Some(self.select(EdgeLabel::Condition)?), + self.try_select(EdgeLabel::Iterator), + Some(self.select(EdgeLabel::CloseParen)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn while_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::WhileKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Condition)?), + Some(self.select(EdgeLabel::CloseParen)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn do_while_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::DoKeyword)?), + Some(self.select(EdgeLabel::Body)?), + Some(self.select(EdgeLabel::WhileKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Condition)?), + Some(self.select(EdgeLabel::CloseParen)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn continue_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ContinueKeyword)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn break_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::BreakKeyword)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn return_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ReturnKeyword)?), + self.try_select(EdgeLabel::Expression), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn emit_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::EmitKeyword)?), + Some(self.select(EdgeLabel::Event)?), + Some(self.select(EdgeLabel::Arguments)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn try_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TryKeyword)?), + Some(self.select(EdgeLabel::Expression)?), + self.try_select(EdgeLabel::Returns), + Some(self.select(EdgeLabel::Body)?), + Some(self.select(EdgeLabel::CatchClauses)?), + ]) + } +} + +impl Helper { + fn catch_clause_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::CatchKeyword)?), + self.try_select(EdgeLabel::Error), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn catch_clause_error_sequence(&mut self) -> Result>> { + Ok(vec![ + self.try_select(EdgeLabel::Name), + Some(self.select(EdgeLabel::Parameters)?), + ]) + } +} + +impl Helper { + fn revert_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::RevertKeyword)?), + self.try_select(EdgeLabel::Error), + Some(self.select(EdgeLabel::Arguments)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn throw_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ThrowKeyword)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn assignment_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn conditional_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::QuestionMark)?), + Some(self.select(EdgeLabel::TrueExpression)?), + Some(self.select(EdgeLabel::Colon)?), + Some(self.select(EdgeLabel::FalseExpression)?), + ]) + } +} + +impl Helper { + fn or_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn and_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn equality_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn comparison_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn bitwise_or_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn bitwise_xor_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn bitwise_and_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn shift_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn additive_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn multiplicative_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn exponentiation_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn postfix_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::Operator)?), + ]) + } +} + +impl Helper { + fn prefix_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::Operand)?), + ]) + } +} + +impl Helper { + fn function_call_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::Arguments)?), + ]) + } +} + +impl Helper { + fn call_options_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Options)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn member_access_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::Period)?), + Some(self.select(EdgeLabel::Member)?), + ]) + } +} + +impl Helper { + fn index_access_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::OpenBracket)?), + self.try_select(EdgeLabel::Start), + self.try_select(EdgeLabel::End), + Some(self.select(EdgeLabel::CloseBracket)?), + ]) + } +} + +impl Helper { + fn index_access_end_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Colon)?), + self.try_select(EdgeLabel::End), + ]) + } +} + +impl Helper { + fn positional_arguments_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Arguments)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn named_arguments_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + self.try_select(EdgeLabel::Arguments), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn named_argument_group_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Arguments)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn named_argument_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Colon)?), + Some(self.select(EdgeLabel::Value)?), + ]) + } +} + +impl Helper { + fn type_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::TypeKeyword)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::TypeName)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn new_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::NewKeyword)?), + Some(self.select(EdgeLabel::TypeName)?), + ]) + } +} + +impl Helper { + fn tuple_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Items)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn tuple_value_sequence(&mut self) -> Result>> { + Ok(vec![self.try_select(EdgeLabel::Expression)]) + } +} + +impl Helper { + fn array_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBracket)?), + Some(self.select(EdgeLabel::Items)?), + Some(self.select(EdgeLabel::CloseBracket)?), + ]) + } +} + +impl Helper { + fn hex_number_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Literal)?), + self.try_select(EdgeLabel::Unit), + ]) + } +} + +impl Helper { + fn decimal_number_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Literal)?), + self.try_select(EdgeLabel::Unit), + ]) + } +} + +impl Helper { + fn yul_block_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBrace)?), + Some(self.select(EdgeLabel::Statements)?), + Some(self.select(EdgeLabel::CloseBrace)?), + ]) + } +} + +impl Helper { + fn yul_function_definition_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::FunctionKeyword)?), + Some(self.select(EdgeLabel::Name)?), + Some(self.select(EdgeLabel::Parameters)?), + self.try_select(EdgeLabel::Returns), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn yul_parameters_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Parameters)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} + +impl Helper { + fn yul_returns_declaration_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::MinusGreaterThan)?), + Some(self.select(EdgeLabel::Variables)?), + ]) + } +} + +impl Helper { + fn yul_variable_declaration_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LetKeyword)?), + Some(self.select(EdgeLabel::Variables)?), + self.try_select(EdgeLabel::Value), + ]) + } +} + +impl Helper { + fn yul_variable_declaration_value_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Assignment)?), + Some(self.select(EdgeLabel::Expression)?), + ]) + } +} + +impl Helper { + fn yul_variable_assignment_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Variables)?), + Some(self.select(EdgeLabel::Assignment)?), + Some(self.select(EdgeLabel::Expression)?), + ]) + } +} + +impl Helper { + fn yul_colon_and_equal_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Colon)?), + Some(self.select(EdgeLabel::Equal)?), + ]) + } +} + +impl Helper { + fn yul_stack_assignment_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Assignment)?), + Some(self.select(EdgeLabel::Variable)?), + ]) + } +} + +impl Helper { + fn yul_equal_and_colon_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Equal)?), + Some(self.select(EdgeLabel::Colon)?), + ]) + } +} + +impl Helper { + fn yul_if_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::IfKeyword)?), + Some(self.select(EdgeLabel::Condition)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn yul_for_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::ForKeyword)?), + Some(self.select(EdgeLabel::Initialization)?), + Some(self.select(EdgeLabel::Condition)?), + Some(self.select(EdgeLabel::Iterator)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn yul_switch_statement_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::SwitchKeyword)?), + Some(self.select(EdgeLabel::Expression)?), + Some(self.select(EdgeLabel::Cases)?), + ]) + } +} + +impl Helper { + fn yul_default_case_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::DefaultKeyword)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn yul_value_case_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::CaseKeyword)?), + Some(self.select(EdgeLabel::Value)?), + Some(self.select(EdgeLabel::Body)?), + ]) + } +} + +impl Helper { + fn yul_leave_statement_sequence(&mut self) -> Result>> { + Ok(vec![Some(self.select(EdgeLabel::LeaveKeyword)?)]) + } +} + +impl Helper { + fn yul_break_statement_sequence(&mut self) -> Result>> { + Ok(vec![Some(self.select(EdgeLabel::BreakKeyword)?)]) + } +} + +impl Helper { + fn yul_continue_statement_sequence(&mut self) -> Result>> { + Ok(vec![Some(self.select(EdgeLabel::ContinueKeyword)?)]) + } +} + +impl Helper { + fn yul_label_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Label)?), + Some(self.select(EdgeLabel::Colon)?), + ]) + } +} + +impl Helper { + fn yul_function_call_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::OpenParen)?), + Some(self.select(EdgeLabel::Arguments)?), + Some(self.select(EdgeLabel::CloseParen)?), + ]) + } +} +// +// Choices: +// + +pub fn select_choice(node: &Rc) -> Result { + let mut helper = Helper::new(node); + + let variant = helper.select(EdgeLabel::Variant)?; + + helper.finalize()?; + Ok(variant) +} + +// +// Repeated: +// + +pub fn select_repeated(node: &Rc) -> Result> { + let mut helper = Helper::new(node); + + let mut items = vec![]; + + while let Some(item) = helper.try_select(EdgeLabel::Item) { + items.push(item); + } + + helper.finalize()?; + Ok(items) +} + +// +// Separated: +// + +pub fn select_separated(node: &Rc) -> Result>> { + let mut helper = Helper::new(node); + + let mut items = vec![]; + let mut separators = vec![]; + + if let Some(first) = helper.try_select(EdgeLabel::Item) { + items.push(first); + + while let Some(separator) = helper.try_select(EdgeLabel::Separator) { + separators.push(separator); + + items.push(helper.select(EdgeLabel::Item)?); + } + } + + helper.finalize()?; + Ok(vec![items, separators]) +} + +// +// Common: +// + +type Result = std::result::Result; + +struct Helper { + node: Rc, + index: usize, +} + +impl Helper { + fn new(node: &Rc) -> Self { + Self { + node: Rc::clone(node), + index: 0, + } + } + + fn select(&mut self, target_label: EdgeLabel) -> Result { + match self.try_select(target_label) { + Some(node) => { + Ok(node) + }, + None => { + Err(format!("Missing child with label '{target_label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + } + } + + fn try_select(&mut self, target_label: EdgeLabel) -> Option { + let (label, node) = self.current()?; + + if label == target_label { + self.index += 1; + Some(node.clone()) + } else { + None + } + } + + fn current(&mut self) -> Option<(EdgeLabel, Node)> { + loop { + let Edge { label, node } = self.node.children.get(self.index)?; + + match label { + // Skip unlabeled nodes: + | None + // Skip trivia: + | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { + self.index += 1; + continue; + } + // Otherwise, return the edge: + Some(other_label) => { + return Some((*other_label, node.clone())); + } + } + } + } + + fn finalize(mut self) -> Result<()> { + match self.current() { + Some((label, _)) => { + Err(format!("Unrecognized child with label '{label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + None => { + Ok(()) + }, + } + } +} diff --git a/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs new file mode 100644 index 0000000000..5b262a1782 --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs @@ -0,0 +1,56 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[path = "generated/selectors.rs"] +mod selectors; + +use crate::wasm_crate::utils::IntoFFI; + +mod ffi { + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::ast::{ + Guest, GuestSelectors, + }; + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Node, NonterminalNode, + }; +} + +mod rust {} + +impl ffi::Guest for crate::wasm_crate::World { + type Selectors = SelectorsWrapper; +} + +//================================================ +// +// resource selectors +// +//================================================ + +pub struct SelectorsWrapper; + +impl ffi::GuestSelectors for SelectorsWrapper { + fn sequence(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_sequence(node._borrow_ffi())? + .into_iter() + .map(|opt| opt.map(|node| node._into_ffi())) + .collect()) + } + + fn choice(node: ffi::NonterminalNode) -> Result { + Ok(selectors::select_choice(node._borrow_ffi())?._into_ffi()) + } + + fn repeated(node: ffi::NonterminalNode) -> Result, String> { + Ok(selectors::select_repeated(node._borrow_ffi())? + .into_iter() + .map(|node| node._into_ffi()) + .collect()) + } + + fn separated(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_separated(node._borrow_ffi())? + .into_iter() + .map(|vec| vec.into_iter().map(|node| node._into_ffi()).collect()) + .collect()) + } +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/cst.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs similarity index 73% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/cst.rs rename to crates/solidity/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs index 8b99766aae..91c5285601 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/cst.rs +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs @@ -1,27 +1,29 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::wit::utils::{ +use crate::wasm_crate::utils::{ define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum, FromFFI, IntoFFI, }; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ - Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, GuestQuery, - GuestQueryMatchIterator, GuestTerminalNode, Node, NonterminalKind, NonterminalNode, - NonterminalNodeBorrow, Query, QueryBorrow, QueryError, QueryMatch, QueryMatchIterator, - QueryMatchIteratorBorrow, TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, - TextRange, + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Cursor, CursorBorrow, Edge, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, + GuestQuery, GuestQueryMatchIterator, GuestTerminalKindExtensions, GuestTerminalNode, Node, + NonterminalKind, NonterminalNode, NonterminalNodeBorrow, Query, QueryBorrow, QueryError, + QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, TerminalKind, TerminalNode, + TerminalNodeBorrow, TextIndex, TextRange, }; } mod rust { - pub use crate::cst::{ - Cursor, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, QueryMatch, - QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, + pub use crate::rust_crate::cst::{ + Cursor, Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, + QueryMatch, QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, }; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { + type TerminalKindExtensions = TerminalKindExtensionsWrapper; + type NonterminalNode = NonterminalNodeWrapper; type TerminalNode = TerminalNodeWrapper; @@ -47,6 +49,24 @@ enum_to_enum!(NonterminalKind); enum_to_enum!(TerminalKind); +//================================================ +// +// resource terminal-kind-extensions +// +//================================================ + +pub struct TerminalKindExtensionsWrapper; + +impl ffi::GuestTerminalKindExtensions for TerminalKindExtensionsWrapper { + fn is_trivia(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_trivia(&kind._from_ffi()) + } + + fn is_valid(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_valid(&kind._from_ffi()) + } +} + //================================================ // // enum edge-label @@ -55,6 +75,22 @@ enum_to_enum!(TerminalKind); enum_to_enum!(EdgeLabel); +//================================================ +// +// 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()), + } + } +} + //================================================ // // resource nonterminal-node @@ -62,24 +98,32 @@ enum_to_enum!(EdgeLabel); //================================================ define_rc_wrapper! { NonterminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::NonterminalKind { self._borrow_ffi().kind._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { + fn text_length(&self) -> ffi::TextIndex { self._borrow_ffi().text_len._into_ffi() } - fn children(&self) -> Vec { - self._borrow_ffi().children.iter().map(|edge| edge.node.clone()._into_ffi()).collect() + fn children(&self) -> Vec { + self._borrow_ffi().children.iter().map(|edge| edge.clone()._into_ffi()).collect() } - 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 { + self._borrow_ffi().unparse() } - fn unparse(&self) -> String { - std::rc::Rc::clone(self._borrow_ffi()).unparse() + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() + } + + 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() } } } @@ -90,31 +134,43 @@ define_rc_wrapper! { NonterminalNode { //================================================ define_rc_wrapper! { TerminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::TerminalKind { self._borrow_ffi().kind._into_ffi() } - fn text(&self) -> String { - self._borrow_ffi().text.clone() + fn text_length(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { - rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + fn children(&self) -> Vec { + Vec::new() + } + + fn unparse(&self) -> String { + self._borrow_ffi().unparse() + } + + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() } } } //================================================ // -// variant node +// record edge // //================================================ -impl IntoFFI for rust::Node { +impl IntoFFI for rust::Edge { #[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()), + fn _into_ffi(self) -> ffi::Edge { + ffi::Edge { + label: self.label.map(|label| label._into_ffi()), + node: self.node._into_ffi(), } } } @@ -162,9 +218,8 @@ define_refcell_wrapper! { Cursor { self._borrow_ffi().text_range()._into_ffi() } - #[allow(clippy::cast_possible_truncation)] fn depth(&self) -> u32 { - self._borrow_ffi().depth() as u32 + self._borrow_ffi().depth().try_into().unwrap() } fn ancestors(&self) -> Vec { @@ -263,11 +318,10 @@ define_wrapper! { Query { impl IntoFFI for rust::QueryError { #[inline] fn _into_ffi(self) -> ffi::QueryError { - #[allow(clippy::cast_possible_truncation)] ffi::QueryError { message: self.message, - row: self.row as u32, - column: self.column as u32, + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } @@ -294,8 +348,7 @@ 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, + query_number: self.query_number.try_into().unwrap(), captures: self .captures .into_iter() @@ -311,27 +364,19 @@ impl IntoFFI for rust::QueryMatch { // //================================================ -impl IntoFFI for rust::TextIndex { +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, + utf8: self.utf8.try_into().unwrap(), + utf16: self.utf16.try_into().unwrap(), + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } -impl IntoFFI for &rust::TextIndex { - #[inline] - fn _into_ffi(self) -> ffi::TextIndex { - (*self)._into_ffi() - } -} - -impl FromFFI for ffi::TextIndex { +impl FromFFI for &ffi::TextIndex { #[inline] fn _from_ffi(self) -> rust::TextIndex { rust::TextIndex { @@ -349,16 +394,6 @@ impl FromFFI for ffi::TextIndex { // //================================================ -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 { @@ -369,7 +404,7 @@ impl IntoFFI for &rust::TextRange { } } -impl FromFFI for ffi::TextRange { +impl FromFFI for &ffi::TextRange { #[inline] fn _from_ffi(self) -> rust::TextRange { rust::TextRange { diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/mod.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/mod.rs similarity index 87% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/mod.rs rename to crates/solidity/outputs/cargo/wasm/src/generated/wrappers/mod.rs index 0bf0d41a7a..e05fee5635 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/mod.rs +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/mod.rs @@ -1,5 +1,5 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +mod ast; mod cst; -mod diagnostic; mod parser; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/parser.rs b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs similarity index 53% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/parser.rs rename to crates/solidity/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs index 56a33eb3ab..311c2b9d8a 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/parser.rs +++ b/crates/solidity/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs @@ -1,24 +1,22 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::diagnostic::Diagnostic; -use crate::wit::utils::{define_wrapper, FromFFI, IntoFFI}; +use crate::wasm_crate::utils::{define_wrapper, FromFFI, IntoFFI}; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ Cursor, Node, TextRange, }; - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; - pub use crate::wit::interface::exports::nomic_foundation::slang::parser::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::parser::{ Guest, GuestParseError, GuestParseOutput, GuestParser, NonterminalKind, ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Parser, ParserBorrow, }; } mod rust { - pub use crate::parser::{ParseError, ParseOutput, Parser}; + pub use crate::rust_crate::parser::{ParseError, ParseOutput, Parser}; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { type Parser = ParserWrapper; type ParseError = ParseErrorWrapper; type ParseOutput = ParseOutputWrapper; @@ -31,15 +29,8 @@ impl ffi::Guest for crate::wit::World { //================================================ define_wrapper! { Parser { - fn new(version: String) -> Result { - semver::Version::parse(&version) - .map_err(|_| format!("Invalid version: {version}")) - .and_then(|version| rust::Parser::new(version).map_err(|e| e.to_string())) - .map(IntoFFI::_into_ffi) - } - - fn version(&self) -> String { - self._borrow_ffi().version.to_string() + fn root_kind() -> ffi::NonterminalKind { + rust::Parser::ROOT_KIND._into_ffi() } fn supported_versions() -> Vec { @@ -49,6 +40,17 @@ define_wrapper! { Parser { .collect() } + fn create(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid semantic version: '{version}'")) + .and_then(|version| rust::Parser::create(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() } @@ -61,17 +63,13 @@ define_wrapper! { Parser { //================================================ 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 text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } - fn message(&self) -> String { - self._borrow_ffi().message() - } + fn message(&self) -> String { + self._borrow_ffi().message() + } } } //================================================ @@ -81,19 +79,19 @@ define_wrapper! { ParseError { //================================================ define_wrapper! { ParseOutput { - fn tree(&self) -> ffi::Node { - self._borrow_ffi().tree()._into_ffi() - } + 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 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 is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } - fn create_tree_cursor(&self) -> ffi::Cursor { - self._borrow_ffi().create_tree_cursor()._into_ffi() - } + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } } } diff --git a/crates/solidity/outputs/cargo/wasm/src/lib.rs b/crates/solidity/outputs/cargo/wasm/src/lib.rs new file mode 100644 index 0000000000..c0082e0a1a --- /dev/null +++ b/crates/solidity/outputs/cargo/wasm/src/lib.rs @@ -0,0 +1,3 @@ +mod generated; + +use {generated as wasm_crate, slang_solidity as rust_crate}; diff --git a/crates/solidity/outputs/npm/package/.gitignore b/crates/solidity/outputs/npm/package/.gitignore new file mode 100644 index 0000000000..53571f1f92 --- /dev/null +++ b/crates/solidity/outputs/npm/package/.gitignore @@ -0,0 +1,3 @@ +# WASM binaries and bindgen files generated during the build: +wasm/generated/*.js +wasm/generated/*.wasm diff --git a/crates/solidity/outputs/npm/package/.npmignore b/crates/solidity/outputs/npm/package/.npmignore new file mode 100644 index 0000000000..4258ca2723 --- /dev/null +++ b/crates/solidity/outputs/npm/package/.npmignore @@ -0,0 +1,10 @@ +# Ignore Everything: +**/** + +# Except: +!target/generated/** +!wasm/** +!CHANGELOG.md +!LICENSE +!package.json +!README.md diff --git a/crates/solidity/outputs/npm/package/build.rs b/crates/solidity/outputs/npm/package/build.rs index 68237b33d7..59e685334f 100644 --- a/crates/solidity/outputs/npm/package/build.rs +++ b/crates/solidity/outputs/npm/package/build.rs @@ -1,13 +1,16 @@ use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; +use codegen_runtime_generator::RuntimeGenerator; use infra_utils::cargo::CargoWorkspace; use solidity_language::SolidityDefinition; fn main() -> Result<()> { let language = SolidityDefinition::create(); + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_npm_package")?.join("src/runtime"); + let output_dir = CargoWorkspace::locate_source_crate("solidity_npm_package")?.join("src/generated"); - OutputLanguage::Npm.generate_runtime(&language, &output_dir) + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) } diff --git a/crates/solidity/outputs/npm/package/package.json b/crates/solidity/outputs/npm/package/package.json index 85b58d928f..89cf79bdb7 100644 --- a/crates/solidity/outputs/npm/package/package.json +++ b/crates/solidity/outputs/npm/package/package.json @@ -1,6 +1,7 @@ { "name": "@nomicfoundation/slang", "version": "0.17.0", + "type": "module", "description": "A modular set of compiler APIs empowering the next generation of Solidity code analysis and developer tooling. Written in Rust and distributed in multiple languages.", "homepage": "https://nomicfoundation.github.io/slang/", "license": "MIT", @@ -27,43 +28,6 @@ "email": "omar@nomic.foundation" } ], - "type": "commonjs", - "devDependencies": { - "@napi-rs/cli": "2.18.4" - }, - "dependencies": { - "@nomicfoundation/slang-darwin-arm64": "0.17.0", - "@nomicfoundation/slang-win32-arm64-msvc": "0.17.0", - "@nomicfoundation/slang-linux-arm64-gnu": "0.17.0", - "@nomicfoundation/slang-linux-arm64-musl": "0.17.0", - "@nomicfoundation/slang-win32-ia32-msvc": "0.17.0", - "@nomicfoundation/slang-darwin-x64": "0.17.0", - "@nomicfoundation/slang-win32-x64-msvc": "0.17.0", - "@nomicfoundation/slang-linux-x64-gnu": "0.17.0", - "@nomicfoundation/slang-linux-x64-musl": "0.17.0" - }, - "napi": { - "triples": { - "defaults": false, - "additional": [ - "aarch64-apple-darwin", - "aarch64-pc-windows-msvc", - "aarch64-unknown-linux-gnu", - "aarch64-unknown-linux-musl", - "i686-pc-windows-msvc", - "x86_64-apple-darwin", - "x86_64-pc-windows-msvc", - "x86_64-unknown-linux-gnu", - "x86_64-unknown-linux-musl" - ] - } - }, - "slangMetadata": { - "targetGlibc": "2.28" - }, - "engines": { - "node": ">= 10" - }, "publishConfig": { "registry": "https://registry.npmjs.org/", "access": "public" @@ -77,5 +41,16 @@ "smart-contracts", "solidity", "tooling" - ] + ], + "__exports_comment__": "__SLANG_NPM_PACKAGE_EXPORTS__ (keep in sync)", + "exports": { + ".": "./target/generated/index.mjs", + "./ast": "./target/generated/ast/index.mjs", + "./cst": "./target/generated/cst/index.mjs", + "./parser": "./target/generated/parser/index.mjs" + }, + "__dependencies_comment__": "__SLANG_NPM_PACKAGE_DEPENDENCIES__ (keep in sync)", + "dependencies": { + "@bytecodealliance/preview2-shim": "0.17.0" + } } diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/darwin-arm64/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/README.md b/crates/solidity/outputs/npm/package/platforms/darwin-arm64/README.md deleted file mode 100644 index bb2fd30a4a..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-darwin-arm64 - -This is the **aarch64-apple-darwin** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/package.json b/crates/solidity/outputs/npm/package/platforms/darwin-arm64/package.json deleted file mode 100644 index 282e76df6d..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-arm64/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-darwin-arm64", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.darwin-arm64.node", - "files": [ - "index.darwin-arm64.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-x64/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/darwin-x64/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-x64/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-x64/README.md b/crates/solidity/outputs/npm/package/platforms/darwin-x64/README.md deleted file mode 100644 index 257ae608de..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-x64/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-darwin-x64 - -This is the **x86_64-apple-darwin** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/darwin-x64/package.json b/crates/solidity/outputs/npm/package/platforms/darwin-x64/package.json deleted file mode 100644 index f0752537d1..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/darwin-x64/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-darwin-x64", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.darwin-x64.node", - "files": [ - "index.darwin-x64.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/README.md b/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/README.md deleted file mode 100644 index fd61832fa4..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-linux-arm64-gnu - -This is the **aarch64-unknown-linux-gnu** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/package.json b/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/package.json deleted file mode 100644 index 8dd43fdec2..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-linux-arm64-gnu", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.linux-arm64-gnu.node", - "files": [ - "index.linux-arm64-gnu.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/README.md b/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/README.md deleted file mode 100644 index 8c20a08a90..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-linux-arm64-musl - -This is the **aarch64-unknown-linux-musl** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/package.json b/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/package.json deleted file mode 100644 index 4b273ee6e3..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-arm64-musl/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-linux-arm64-musl", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.linux-arm64-musl.node", - "files": [ - "index.linux-arm64-musl.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/README.md b/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/README.md deleted file mode 100644 index 1484640f04..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-linux-x64-gnu - -This is the **x86_64-unknown-linux-gnu** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/package.json b/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/package.json deleted file mode 100644 index 3cc6c41173..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-gnu/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-linux-x64-gnu", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.linux-x64-gnu.node", - "files": [ - "index.linux-x64-gnu.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/README.md b/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/README.md deleted file mode 100644 index 7cbc86c210..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-linux-x64-musl - -This is the **x86_64-unknown-linux-musl** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/package.json b/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/package.json deleted file mode 100644 index bebbcaccbc..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/linux-x64-musl/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-linux-x64-musl", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.linux-x64-musl.node", - "files": [ - "index.linux-x64-musl.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/README.md b/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/README.md deleted file mode 100644 index f85e250a21..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-win32-arm64-msvc - -This is the **aarch64-pc-windows-msvc** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/package.json b/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/package.json deleted file mode 100644 index abe88c67da..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-win32-arm64-msvc", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.win32-arm64-msvc.node", - "files": [ - "index.win32-arm64-msvc.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/README.md b/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/README.md deleted file mode 100644 index 51383894fa..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-win32-ia32-msvc - -This is the **i686-pc-windows-msvc** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/package.json b/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/package.json deleted file mode 100644 index 6b02bb57a8..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-win32-ia32-msvc", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.win32-ia32-msvc.node", - "files": [ - "index.win32-ia32-msvc.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/CHANGELOG.md b/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/CHANGELOG.md deleted file mode 100644 index bb3c01b3e7..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/CHANGELOG.md +++ /dev/null @@ -1,378 +0,0 @@ -# changelog - -## 0.17.0 - -### Minor Changes - -- [#1079](https://github.com/NomicFoundation/slang/pull/1079) [`43b389e`](https://github.com/NomicFoundation/slang/commit/43b389e9db59054774e6346dca7e71c307192ebb) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move the Rust CLI into a separate `slang_solidity_cli` crate. - -### Patch Changes - -- [#1086](https://github.com/NomicFoundation/slang/pull/1086) [`f749e53`](https://github.com/NomicFoundation/slang/commit/f749e536a377b1612b623eb8277abb2b59019026) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure. - -## 0.16.0 - -### Minor Changes - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: queries now ignore trivia nodes. - -- [#1030](https://github.com/NomicFoundation/slang/pull/1030) [`7e467ce`](https://github.com/NomicFoundation/slang/commit/7e467ce199cb07acb443da9f542fbcc74f2a5321) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: remove the ellipsis query `...` operator making it implicit, add an adjacency operator `.`. - -### Patch Changes - -- [#1015](https://github.com/NomicFoundation/slang/pull/1015) [`369ee30`](https://github.com/NomicFoundation/slang/commit/369ee309325ef57c7cd6f29e2f7adc4f9ec09c88) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.79.0`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Compute row and column information for query parser errors. - -- [#1048](https://github.com/NomicFoundation/slang/pull/1048) [`c408caa`](https://github.com/NomicFoundation/slang/commit/c408caae1826095cc2f2c01caf9be58ab5ff8eee) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul multiple variables declaration - -- [#1047](https://github.com/NomicFoundation/slang/pull/1047) [`2b32045`](https://github.com/NomicFoundation/slang/commit/2b3204549af27ea3782da2a9a2de470db13a7402) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline `MemberAccess` enum into the parent `MemberAccessExpression` - -- [#1062](https://github.com/NomicFoundation/slang/pull/1062) [`6b05496`](https://github.com/NomicFoundation/slang/commit/6b05496cbd19b5a7f65033fb223c1bcd3d448738) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack assignments operator `=:`. - -- [#1052](https://github.com/NomicFoundation/slang/pull/1052) [`54c9067`](https://github.com/NomicFoundation/slang/commit/54c9067aa6c587ff93cac6575726a9068a9bb758) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query Language: Improve reporting when an error occurs attempting to parse edge labels or node kinds. - -- [#1037](https://github.com/NomicFoundation/slang/pull/1037) [`2a74f91`](https://github.com/NomicFoundation/slang/commit/2a74f91ed8e67fc3d315afd49f593dfef52f0e4d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix `ExponentiationExpression` associativity before `0.8.0` - -## 0.15.1 - -### Patch Changes - -- [#1012](https://github.com/NomicFoundation/slang/pull/1012) [`9ca51b4`](https://github.com/NomicFoundation/slang/commit/9ca51b431e6d9e52b537683bf618d8852103936b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `QueryMatch` to public API - -## 0.15.0 - -### Minor Changes - -- [#975](https://github.com/NomicFoundation/slang/pull/975) [`46b1dde`](https://github.com/NomicFoundation/slang/commit/46b1dde2e39903cff6398d5da3a4d1a1820f0095) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `QueryResult` to `QueryMatch`, and its `bindings` to `captures`. - -- [#971](https://github.com/NomicFoundation/slang/pull/971) [`be943b7`](https://github.com/NomicFoundation/slang/commit/be943b7349e4c4b7589d93cf670bc8453125b229) Thanks [@Xanewok](https://github.com/Xanewok)! - Rename `RuleKind` to `NonterminalKind`, `TokenKind` to `TerminalKind`, and `NodeLabel` to `EdgeLabel`. - -- [#963](https://github.com/NomicFoundation/slang/pull/963) [`a5593f9`](https://github.com/NomicFoundation/slang/commit/a5593f981b1df133449264c995c91ac738981474) Thanks [@Xanewok](https://github.com/Xanewok)! - Introduce a `Diagnostic` API for compiler errors, warnings etc. - -### Patch Changes - -- [#996](https://github.com/NomicFoundation/slang/pull/996) [`cdc153d`](https://github.com/NomicFoundation/slang/commit/cdc153dbb149c277f6f0d00ed95bbac1e5bec8f1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add support for version `0.8.26`. - -- [#983](https://github.com/NomicFoundation/slang/pull/983) [`ea31417`](https://github.com/NomicFoundation/slang/commit/ea3141741ef3e491b2125f0d24d5db58c2f5d600) Thanks [@ggiraldez](https://github.com/ggiraldez)! - Expose the language root non-terminal kind at `Language.rootKind()`. - -- [#965](https://github.com/NomicFoundation/slang/pull/965) [`61b6b06`](https://github.com/NomicFoundation/slang/commit/61b6b06deaa1db86a21c5fed675cd665ed2c42a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - refactor CST building and querying utilities into a separate `metaslang_cst` crate. - -- [#997](https://github.com/NomicFoundation/slang/pull/997) [`84ad856`](https://github.com/NomicFoundation/slang/commit/84ad856b344e7c17376b38c420a7952556dc4ff5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support stack assignments in Yul before `0.5.0`. - -## 0.14.2 - -### Patch Changes - -- [#948](https://github.com/NomicFoundation/slang/pull/948) [`ce88cb7`](https://github.com/NomicFoundation/slang/commit/ce88cb7a6fd945b59ccc967cfd20f423dadc36fc) Thanks [@Xanewok](https://github.com/Xanewok)! - Restrict the grammar to correctly only allow an identifier in Yul variable declaration - -- [#945](https://github.com/NomicFoundation/slang/pull/945) [`e8f80d8`](https://github.com/NomicFoundation/slang/commit/e8f80d867b4b9d02413f42a8ece2630a43bc7494) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `.address` built-in access in Yul paths - -## 0.14.1 - -### Patch Changes - -- [#943](https://github.com/NomicFoundation/slang/pull/943) [`a561fb1`](https://github.com/NomicFoundation/slang/commit/a561fb161eb7c18c838c85f71d132764d1d04050) Thanks [@Xanewok](https://github.com/Xanewok)! - Support Solidity 0.8.25 - -## 0.14.0 - -### Minor Changes - -- [#753](https://github.com/NomicFoundation/slang/pull/753) [`b35c763`](https://github.com/NomicFoundation/slang/commit/b35c7630ab7240304e67a43734700cf359acde0b) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add tree query implementation as `Query::parse` and `Cursor::query` - -- [#755](https://github.com/NomicFoundation/slang/pull/755) [`8c260fc`](https://github.com/NomicFoundation/slang/commit/8c260fcb7e3111191cd33dd527817fb51119eac4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support parsing NatSpec comments - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers - -- [#886](https://github.com/NomicFoundation/slang/pull/886) [`0125717`](https://github.com/NomicFoundation/slang/commit/0125717fb0b48a5342a8452f18080db13e68fb6b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `TokenKind::is_trivia` - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Add support for constant function modifier removed in 0.5.0 - -- [#885](https://github.com/NomicFoundation/slang/pull/885) [`a9bd8da`](https://github.com/NomicFoundation/slang/commit/a9bd8da018469739832f71e38437caa83087baf0) Thanks [@Xanewok](https://github.com/Xanewok)! - Flatten the trivia syntax nodes into sibling tokens - -- [#908](https://github.com/NomicFoundation/slang/pull/908) [`ab3688b`](https://github.com/NomicFoundation/slang/commit/ab3688bb99a60862c506566ac6122cd9c1155c57) Thanks [@Xanewok](https://github.com/Xanewok)! - Add RuleNode/TokenNode::toJSON() in the TypeScript API - -### Patch Changes - -- [#801](https://github.com/NomicFoundation/slang/pull/801) [`ecbba49`](https://github.com/NomicFoundation/slang/commit/ecbba49c7ac25e37b8d317fb60fab7340c0628a5) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve pragma keywords in all versions - -- [#869](https://github.com/NomicFoundation/slang/pull/869) [`951b58d`](https://github.com/NomicFoundation/slang/commit/951b58ddb3eaea600ddf44427a82649761c6b651) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support dots in yul identifiers from `0.5.8` till `0.7.0` - -- [#890](https://github.com/NomicFoundation/slang/pull/890) [`1ff8599`](https://github.com/NomicFoundation/slang/commit/1ff85993f25d92b38d0a500baa6ee48669a1b62a) Thanks [@Xanewok](https://github.com/Xanewok)! - Mark `override` as being a valid attribute only after 0.6.0 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support unicode characters in string literals up to `0.7.0` - -- [#797](https://github.com/NomicFoundation/slang/pull/797) [`86f36d7`](https://github.com/NomicFoundation/slang/commit/86f36d71e60a44261ec114339e931dd3d24cd4a4) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix source locations for unicode characters in error reports - -- [#854](https://github.com/NomicFoundation/slang/pull/854) [`4b8970b`](https://github.com/NomicFoundation/slang/commit/4b8970b47ef7a2d1d51339cf5020a3e0f168b9aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - parse line breaks without newlines - -- [#844](https://github.com/NomicFoundation/slang/pull/844) [`f62de9e`](https://github.com/NomicFoundation/slang/commit/f62de9ea3fc2049ee11e5dbeff3dc51eb1ca984e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing empty `/**/` comments - -- [#799](https://github.com/NomicFoundation/slang/pull/799) [`303dda9`](https://github.com/NomicFoundation/slang/commit/303dda95c08b20450d03116765c210ece64a0864) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prevent parsing multiple literals under `StringExpression` before `0.5.14` - -- [#847](https://github.com/NomicFoundation/slang/pull/847) [`6b6f260`](https://github.com/NomicFoundation/slang/commit/6b6f2603e3ba07c0a7dede0f96082369dc1df940) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - prioritize parsing `MultiLineComment` over `MultiLineNatSpecComment` - -- [#796](https://github.com/NomicFoundation/slang/pull/796) [`59e1e53`](https://github.com/NomicFoundation/slang/commit/59e1e53e7efa52355c273d7cef1a3974de13d88d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `public` and `internal` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#756](https://github.com/NomicFoundation/slang/pull/756) [`e839817`](https://github.com/NomicFoundation/slang/commit/e8398173f62d48596669628afc7c8b3572a15291) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix parsing `payable` primary expressions - -- [#851](https://github.com/NomicFoundation/slang/pull/851) [`67dfde8`](https://github.com/NomicFoundation/slang/commit/67dfde81a6d00101a9ed133104f15da5d46662b6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix selection order of prefix/postfix AST fields - -- [#857](https://github.com/NomicFoundation/slang/pull/857) [`f677d5e`](https://github.com/NomicFoundation/slang/commit/f677d5eff40c4bfcf1db2fc4e63cdf37457fe467) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `FieldName` to `NodeLabel` - -- [#852](https://github.com/NomicFoundation/slang/pull/852) [`ca79eca`](https://github.com/NomicFoundation/slang/commit/ca79ecaa522e531420b42ffba67da192c1e5fdb2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow parsing `ColonEqual` as two separate tokens before `0.5.5` - -- [#889](https://github.com/NomicFoundation/slang/pull/889) [`ce5050f`](https://github.com/NomicFoundation/slang/commit/ce5050f95195fdd018a38a0351d8525f7d62073a) Thanks [@Xanewok](https://github.com/Xanewok)! - Support `delete` as an expression rather than a statement - -- [#923](https://github.com/NomicFoundation/slang/pull/923) [`bb30fc1`](https://github.com/NomicFoundation/slang/commit/bb30fc1e28a0fe806f8954a0d2779d903f3f4da7) Thanks [@Xanewok](https://github.com/Xanewok)! - Support arbitrary ASCII escape sequences in string literals until 0.4.25 - -- [#887](https://github.com/NomicFoundation/slang/pull/887) [`dff1201`](https://github.com/NomicFoundation/slang/commit/dff12011c549d68b20ecd54251af764643fb72db) Thanks [@Xanewok](https://github.com/Xanewok)! - Support view and pure function modifiers only from 0.4.16 - -- [#800](https://github.com/NomicFoundation/slang/pull/800) [`d1827ff`](https://github.com/NomicFoundation/slang/commit/d1827ff7e1010493ff5487532a5ee0c77d355aa2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `AsciiStringLiteral` to `StringLiteral` - -- [#838](https://github.com/NomicFoundation/slang/pull/838) [`ad98d1c`](https://github.com/NomicFoundation/slang/commit/ad98d1c7d9f9f7cb12b4b6184c04c9b680e6d70a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust `1.76.0` - -- [#849](https://github.com/NomicFoundation/slang/pull/849) [`5c42e0e`](https://github.com/NomicFoundation/slang/commit/5c42e0ef5f3afe0355614967cb6d2daa31518ccf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `override` and `virtual` to `ConstructorAttribute` - -- [#862](https://github.com/NomicFoundation/slang/pull/862) [`5e37ea0`](https://github.com/NomicFoundation/slang/commit/5e37ea0c40e929e0888b6297fa6dd92952d9cd73) Thanks [@Xanewok](https://github.com/Xanewok)! - allow call options as a post-fix expression - -- [#786](https://github.com/NomicFoundation/slang/pull/786) [`0bfa6b7`](https://github.com/NomicFoundation/slang/commit/0bfa6b7397cd25aca713b30628c6d06e761b416a) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul label statements before `0.5.0` - -- [#839](https://github.com/NomicFoundation/slang/pull/839) [`2d698eb`](https://github.com/NomicFoundation/slang/commit/2d698ebe469110b85f539d6e0c75b503cd4ce57e) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support string literals in version pragmas - -- [#891](https://github.com/NomicFoundation/slang/pull/891) [`70c9d7d`](https://github.com/NomicFoundation/slang/commit/70c9d7deebddb0f22114b7b05ddc85da6dcceaaf) Thanks [@Xanewok](https://github.com/Xanewok)! - Fix parsing `.member` member access expression - -- [#842](https://github.com/NomicFoundation/slang/pull/842) [`2069126`](https://github.com/NomicFoundation/slang/commit/20691263fb6967195bee30fba92abdfb06daa6fa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `private` to `UnnamedFunctionAttribute` till `0.5.0` - -- [#840](https://github.com/NomicFoundation/slang/pull/840) [`7fb0d20`](https://github.com/NomicFoundation/slang/commit/7fb0d20655024daf71c872a6ef95aa30277a1366) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - allow `var` in `TupleDeconstructionStatement` before `0.5.0` - -## 0.13.1 - -### Patch Changes - -- [#748](https://github.com/NomicFoundation/slang/pull/748) [`c289cbf7`](https://github.com/NomicFoundation/slang/commit/c289cbf7e22118881818b82d0ffc5933a424a7aa) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Properly parse EVM built-ins up till Paris/Solidity 0.8.18 - -## 0.13.0 - -### Minor Changes - -- [#710](https://github.com/NomicFoundation/slang/pull/710) [`2025b6cb`](https://github.com/NomicFoundation/slang/commit/2025b6cb23dc320b413b482ed1fe8455229b7d84) Thanks [@Xanewok](https://github.com/Xanewok)! - CST children nodes are now named - -- [#723](https://github.com/NomicFoundation/slang/pull/723) [`b3dc6bcd`](https://github.com/NomicFoundation/slang/commit/b3dc6bcdc1834d266a87d483927894617bf8e817) Thanks [@Xanewok](https://github.com/Xanewok)! - Properly parse unreserved keywords in an identifier position, i.e. `from`, `emit`, `global` etc. - -- [#728](https://github.com/NomicFoundation/slang/pull/728) [`662a672c`](https://github.com/NomicFoundation/slang/commit/662a672cd661b9f1bf4c18587acf68111fd1f2e8) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove Language#scan API; use the parser API instead - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - introduce strong types for all Solidity non terminals in the TypeScript API. - -### Patch Changes - -- [#719](https://github.com/NomicFoundation/slang/pull/719) [`1ad6bb37`](https://github.com/NomicFoundation/slang/commit/1ad6bb37337aa28d9344380c5c9eb1945e908271) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unify Rust/TypeScript node helpers: `*_with_kind()`, `*_with_kinds()`, `*_is_kind()`), ... - -- [#731](https://github.com/NomicFoundation/slang/pull/731) [`3deaea2e`](https://github.com/NomicFoundation/slang/commit/3deaea2eb82ce33dbccc54d1a79b9cf5657385ac) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add `RuleNode.unparse()` to the TypeScript API - -## 0.12.0 - -### Minor Changes - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove `ProductionKind` in favor of `RuleKind` - -- [#699](https://github.com/NomicFoundation/slang/pull/699) [`ddfebfe9`](https://github.com/NomicFoundation/slang/commit/ddfebfe988345136007431f8ea2efac19fd7e887) Thanks [@Xanewok](https://github.com/Xanewok)! - Allow parsing individual precedence expressions, like `ShiftExpression` - -- [#665](https://github.com/NomicFoundation/slang/pull/665) [`4b5f8b46`](https://github.com/NomicFoundation/slang/commit/4b5f8b467d4cbab72cf27a539bb5ca8c71090dd6) Thanks [@Xanewok](https://github.com/Xanewok)! - Remove the CST Visitor API in favor of the Cursor API - -- [#666](https://github.com/NomicFoundation/slang/pull/666) [`0434b68c`](https://github.com/NomicFoundation/slang/commit/0434b68c9ef9cd1d1dcc07d7ed50e6d63645319b) Thanks [@Xanewok](https://github.com/Xanewok)! - Add `Node::unparse()` that allows to reconstruct the source code from the CST node - -- [#675](https://github.com/NomicFoundation/slang/pull/675) [`daea4b7f`](https://github.com/NomicFoundation/slang/commit/daea4b7f954ff1e918b9191aff40ee95c10a4db2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `Cursor`'s `pathRuleNodes()` to `ancestors()` in the NodeJS API. - -- [#676](https://github.com/NomicFoundation/slang/pull/676) [`b496d361`](https://github.com/NomicFoundation/slang/commit/b496d36120700347bcbcc25b948eb46814fd5412) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Fix NAPI `cursor` types and expose `cursor.depth`. - -### Patch Changes - -- [#685](https://github.com/NomicFoundation/slang/pull/685) [`b5fca94a`](https://github.com/NomicFoundation/slang/commit/b5fca94af917a2f0418c224b3101885c02e5cb9c) Thanks [@Xanewok](https://github.com/Xanewok)! - `bytes` is now properly recognized as a reserved word - -- [#660](https://github.com/NomicFoundation/slang/pull/660) [`97028991`](https://github.com/NomicFoundation/slang/commit/9702899164f0540a49f2e0f7f19d82fbd04b1d1b) Thanks [@Xanewok](https://github.com/Xanewok)! - Drop List suffix from collection grammar rule names - -## 0.11.0 - -### Minor Changes - -- [#625](https://github.com/NomicFoundation/slang/pull/625) [`7bb650b`](https://github.com/NomicFoundation/slang/commit/7bb650b12ae793a318dc5b7839fb93915c88828e) Thanks [@Xanewok](https://github.com/Xanewok)! - The CST Cursor now implements the Iterator trait as part of the Rust API - -- [#647](https://github.com/NomicFoundation/slang/pull/647) [`b1dced3`](https://github.com/NomicFoundation/slang/commit/b1dced355ce83f3bd858c02837d67665f7ef281d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Require specifying an initial offset when creating a CST cursor. - -### Patch Changes - -- [#648](https://github.com/NomicFoundation/slang/pull/648) [`2327bf5`](https://github.com/NomicFoundation/slang/commit/2327bf5d8c40d85edd0cc80fe9e36d367a1a3336) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Support Solidity v0.8.22. - -- [#623](https://github.com/NomicFoundation/slang/pull/623) [`80114a8`](https://github.com/NomicFoundation/slang/commit/80114a833dc8249447c382bf457215b1a4d9e5ae) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Correct the types in the TS api by adding the correct namespaces to type references - -## 0.10.1 - -### Patch Changes - -- [#615](https://github.com/NomicFoundation/slang/pull/615) [`06cbbe8`](https://github.com/NomicFoundation/slang/commit/06cbbe88bc68928ad44046a96c31ad6e53fbf76c) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - `cursor` method is now exposed in Typescript API - -## 0.10.0 - -### Minor Changes - -- [#595](https://github.com/NomicFoundation/slang/pull/595) [`1a258c4`](https://github.com/NomicFoundation/slang/commit/1a258c49432eac06dac7055bc427e68af1fa3875) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt error recovery when parsing incomplete lists - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Parsing operators with missing operands should no longer panic - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Inline parse rules are no longer exposed to the API. - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are no longer available as methods - use next_token instead - -- [#564](https://github.com/NomicFoundation/slang/pull/564) [`e326a06`](https://github.com/NomicFoundation/slang/commit/e326a064da559c974fbb7a199090e9e5a313abb8) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Scanners are now grouped into contexts to deal with contextual scanning - -### Patch Changes - -- [#601](https://github.com/NomicFoundation/slang/pull/601) [`cbd2a79`](https://github.com/NomicFoundation/slang/commit/cbd2a79658849c0029bb6a5ccc0b086564c28fe0) Thanks [@Xanewok](https://github.com/Xanewok)! - Attempt parser error recovery between bracket delimiters - -- [#599](https://github.com/NomicFoundation/slang/pull/599) [`4bbad48`](https://github.com/NomicFoundation/slang/commit/4bbad48d45ae7bde8a22198b33f790b7c792b319) Thanks [@Xanewok](https://github.com/Xanewok)! - Use correct versions for the `revert` and `global` keywords - -- [#561](https://github.com/NomicFoundation/slang/pull/561) [`cb6a138`](https://github.com/NomicFoundation/slang/commit/cb6a1384cb6f04926def3e4c1fe7a0b12a67143c) Thanks [@Xanewok](https://github.com/Xanewok)! - Add preliminary documentation for the `solidity_language` Rust package - -- [#603](https://github.com/NomicFoundation/slang/pull/603) [`be59a10`](https://github.com/NomicFoundation/slang/commit/be59a10c937542f0413a34fd84d84ec4d4400f6d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.72.0 - -## 0.9.0 - -### Minor Changes - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add a Rust Cursor API and refactor the Rust Visitor API to run on top of it. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Move Visitor et al to node:: namespace, which is where Cursor is. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Rename `range` functions that return a TextRange to `text_range` - -### Patch Changes - -- [#543](https://github.com/NomicFoundation/slang/pull/543) [`7a34599`](https://github.com/NomicFoundation/slang/commit/7a34599f6b237b03a0f8ba92755cae6107589e37) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Move `syntax::parser::ProductionKind` to `syntax::nodes` namespace. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add TokenNode.text to the TS API. - -- [#540](https://github.com/NomicFoundation/slang/pull/540) [`0d04f95`](https://github.com/NomicFoundation/slang/commit/0d04f959bf1f5831c912d5109de3d933cfaa6266) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Add first pass of Typescript binding to the Cursor API, but no TS Visitor yet. - -- [#545](https://github.com/NomicFoundation/slang/pull/545) [`e73658a`](https://github.com/NomicFoundation/slang/commit/e73658ae4e777e78a01e213f213e2a5dc13e5cba) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - render EBNF grammar on top of each `ProductionKind`, `RuleKind`, and `TokenKind`. - -- [#558](https://github.com/NomicFoundation/slang/pull/558) [`95bbc50`](https://github.com/NomicFoundation/slang/commit/95bbc5025fbf63b8d4e07f7652a70a7f66363db6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Correct versioning for `SourceUnitMember` and `ContractMember` children. - -## 0.8.0 - -### Minor Changes - -- [#513](https://github.com/NomicFoundation/slang/pull/513) [`7e01250`](https://github.com/NomicFoundation/slang/commit/7e012501c04e639b54cd150e3736683ee2c2606f) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Typescript API now has TextIndex and TextRange types that are returned from the appropriate methods rather than tuples. - -### Patch Changes - -- [#527](https://github.com/NomicFoundation/slang/pull/527) [`7ccca87`](https://github.com/NomicFoundation/slang/commit/7ccca87beaa9cb96ad294d1af8a02f115481b71a) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix pratt parser behavior in the face of error correction -- [#531](https://github.com/NomicFoundation/slang/pull/531) [`e3450be4`](https://github.com/NomicFoundation/slang/commit/e3450be4722845bcfce7a9ec3b3046ba6eb6961d) Thanks [@alcuadrado](https://github.com/alcuadrado)! - Make ESM named imports work in Node.js. - -## 0.7.0 - -### Minor Changes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Added error recovery i.e. a CST is _always_ produced, even if there are errors. The erroneous/skipped text is in the CST as a `TokenKind::SKIPPED` token. - -- [#501](https://github.com/NomicFoundation/slang/pull/501) [`cb221fe`](https://github.com/NomicFoundation/slang/commit/cb221fed784e8a2eb59f17907412149c7b415ed8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - generate typescript string enums for CST kinds - -- [#517](https://github.com/NomicFoundation/slang/pull/517) [`8bd5446`](https://github.com/NomicFoundation/slang/commit/8bd544695a6dd4880a00d0cecf8d13ad79b238d3) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - extract inlined and sub-expressions in language grammar - -- [#518](https://github.com/NomicFoundation/slang/pull/518) [`b3b562b`](https://github.com/NomicFoundation/slang/commit/b3b562be6365fab25b97e54746a7500b9e7bd595) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fill in missing CST node names - -- [#515](https://github.com/NomicFoundation/slang/pull/515) [`f24e873`](https://github.com/NomicFoundation/slang/commit/f24e873a93cbcef53aad1fa5eed1ea9ab1af1c04) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - switch over the NPM package to use CommonJS modules instead of ES modules. - -- [#498](https://github.com/NomicFoundation/slang/pull/498) [`44f1ff7`](https://github.com/NomicFoundation/slang/commit/44f1ff70100d6e2f8afe54c7ff87e24a8479e4b9) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - flatten unnamed CST nodes into parent nodes - -- [#502](https://github.com/NomicFoundation/slang/pull/502) [`c383238`](https://github.com/NomicFoundation/slang/commit/c383238c1f51157b37ec63bc99e63fb85c1bc224) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Use the Rowan model for the CST i.e. TokenNodes contain the string content, and RuleNodes contain only the combined _length_ of their children's text. - -- [#499](https://github.com/NomicFoundation/slang/pull/499) [`1582d60`](https://github.com/NomicFoundation/slang/commit/1582d60c7ef81a785db0b9e3cb4d074d9cb6d442) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - preserve correct ranges on empty rule nodes - -- [#500](https://github.com/NomicFoundation/slang/pull/500) [`73ddac9`](https://github.com/NomicFoundation/slang/commit/73ddac9ca972f80aa9a0321de7f94c47b505d7a6) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inlining CST nodes that offer no additional syntactic information - -- [#512](https://github.com/NomicFoundation/slang/pull/512) [`72dc3d3`](https://github.com/NomicFoundation/slang/commit/72dc3d3d90bc6a02d36836cc1fed17f5be5de2fb) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Expression productions now correctly wrap the recursive 'calls' in a rule node - -## 0.6.0 - -### Minor Changes - -- [#490](https://github.com/NomicFoundation/slang/pull/490) [`ea8e7e7`](https://github.com/NomicFoundation/slang/commit/ea8e7e771fef7fd9195bcc3004b08fc132c8990d) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - provide API to list supported language versions - -- [#489](https://github.com/NomicFoundation/slang/pull/489) [`15c34a7`](https://github.com/NomicFoundation/slang/commit/15c34a7bb0268bf26eaa6535dd637f73349596c8) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - replace panics with JS exceptions in npm package - -### Patch Changes - -- [#488](https://github.com/NomicFoundation/slang/pull/488) [`d7f171c`](https://github.com/NomicFoundation/slang/commit/d7f171cf1e2da375a7ededd034a62fc6b723d44d) Thanks [@DaniPopes](https://github.com/DaniPopes)! - introduce a `cli` Cargo feature to compile the CLI binary - -## 0.5.0 - -### Minor Changes - -- [#475](https://github.com/NomicFoundation/slang/pull/475) [`0cdfe86`](https://github.com/NomicFoundation/slang/commit/0cdfe86037bfe2f1f8be66a69e8e7d7bdbf06364) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - match TypeScript and Rust API namespaces - -- [#477](https://github.com/NomicFoundation/slang/pull/477) [`13c85a2`](https://github.com/NomicFoundation/slang/commit/13c85a2a3e4e97894d9f24a3e2886a08ffe6e569) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move expression operators into separate nodes - -- [#481](https://github.com/NomicFoundation/slang/pull/481) [`0269f2b`](https://github.com/NomicFoundation/slang/commit/0269f2b9de3f6711055119e1f40c3f036fe3a81f) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix grammar versions of individual keywords - -- [#473](https://github.com/NomicFoundation/slang/pull/473) [`11d8cb0`](https://github.com/NomicFoundation/slang/commit/11d8cb0658e01f16b7afd808f31d1da88e967679) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust 1.69.0 - -## 0.4.0 - -### Minor Changes - -- [#458](https://github.com/NomicFoundation/slang/pull/458) [`c0fc7e9`](https://github.com/NomicFoundation/slang/commit/c0fc7e95b87eb1ddca4f9e0003136fcbe74f5798) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Record both character and byte offsets for input positions - -- [#463](https://github.com/NomicFoundation/slang/pull/463) [`0958d6b`](https://github.com/NomicFoundation/slang/commit/0958d6baadba3295df9307e421ddd0a41ef3aaa0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - use `number` and getters in npm public API - -## 0.3.0 - -### Minor Changes - -- [#457](https://github.com/NomicFoundation/slang/pull/457) [`b7aae2a`](https://github.com/NomicFoundation/slang/commit/b7aae2ad891f940ee764365ac12c75fd1cb47687) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - minor grammar fixes - -- [#453](https://github.com/NomicFoundation/slang/pull/453) [`0f2f9ab`](https://github.com/NomicFoundation/slang/commit/0f2f9abec3f2525640d25bf1f288b769917fbc61) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - move Rust's `syntax::Parser::Language` API to root module - -- [#454](https://github.com/NomicFoundation/slang/pull/454) [`85dec01`](https://github.com/NomicFoundation/slang/commit/85dec0196eafa337065233de03c30d36211b03cf) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - moving to Rust version 1.65.0 - -- [#456](https://github.com/NomicFoundation/slang/pull/456) [`c6d1041`](https://github.com/NomicFoundation/slang/commit/c6d10417da440f15e1c074b7d8b5d13d38e95519) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - expose `ParseError` API - -- [#451](https://github.com/NomicFoundation/slang/pull/451) [`78f633c`](https://github.com/NomicFoundation/slang/commit/78f633cb5977d358b4bcc468151359a4301089b2) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - rename `VisitorExitResponse::StepIn` to `VisitorExitResponse::Continue` - -## 0.2.1 - -### Patch Changes - -- [#444](https://github.com/NomicFoundation/slang/pull/444) [`a858e2c`](https://github.com/NomicFoundation/slang/commit/a858e2c842db3b2183821fb92ed26af6b433e823) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - Fix HexLiteral cannot have NumberUnit - -## 0.2.0 - -### Minor Changes - -- [#435](https://github.com/NomicFoundation/slang/pull/435) [`2a5b193`](https://github.com/NomicFoundation/slang/commit/2a5b1930b20024359fbaf06b6e9748585d7423ff) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support user defined operators - -### Patch Changes - -- [#416](https://github.com/NomicFoundation/slang/pull/416) [`fb977a5`](https://github.com/NomicFoundation/slang/commit/fb977a52b152a1ce8d8ce92db4bb00fcfb5881c1) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix primary expressions parser order - -- [#434](https://github.com/NomicFoundation/slang/pull/434) [`beb3708`](https://github.com/NomicFoundation/slang/commit/beb3708218ec797614ba283a13f1854d5f3c7239) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix UnicodeStringLiteral versioning - -- [#430](https://github.com/NomicFoundation/slang/pull/430) [`8b7492e`](https://github.com/NomicFoundation/slang/commit/8b7492e65ec7261176e444dca2563a82603b43b0) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update READMEs with links to packages and user guides. - -- [#425](https://github.com/NomicFoundation/slang/pull/425) [`9b49b3d`](https://github.com/NomicFoundation/slang/commit/9b49b3d827536e707d78a6bc349fc82698237b75) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - add user guides to rust crate and npm packages. - -- [#432](https://github.com/NomicFoundation/slang/pull/432) [`1d1a8bb`](https://github.com/NomicFoundation/slang/commit/1d1a8bb5503c510a470bb99a18632c3e51a587ec) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix FunctionCallOptions versioning - -- [#427](https://github.com/NomicFoundation/slang/pull/427) [`1103916`](https://github.com/NomicFoundation/slang/commit/11039163ac3a3b66a74fa85683bde1c380a519f4) Thanks [@AntonyBlakey](https://github.com/AntonyBlakey)! - fix VariableDeclarationStatement versioning - -## 0.1.1 - -### Patch Changes - -- [#412](https://github.com/NomicFoundation/slang/pull/412) [`9cac1a04`](https://github.com/NomicFoundation/slang/commit/9cac1a04670fa870c15cee1bd20e0e78c1d213db) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - publish npm packages - -## 0.1.0 - -### Minor Changes - -- [#396](https://github.com/NomicFoundation/slang/pull/396) [`621b338`](https://github.com/NomicFoundation/slang/commit/621b33838c74415c46ab157205068008e05c5b9b) Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - Initial release. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/README.md b/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/README.md deleted file mode 100644 index 9aafdca9c6..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/README.md +++ /dev/null @@ -1,5 +0,0 @@ - - -# @nomicfoundation/slang-win32-x64-msvc - -This is the **x86_64-pc-windows-msvc** binary for `@nomicfoundation/slang`. diff --git a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/package.json b/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/package.json deleted file mode 100644 index 7f2c0c6a23..0000000000 --- a/crates/solidity/outputs/npm/package/platforms/win32-x64-msvc/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "@nomicfoundation/slang-win32-x64-msvc", - "version": "0.17.0", - "description": "Platform-specific binaries for @nomicfoundation/slang.", - "homepage": "https://nomicfoundation.github.io/slang/", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NomicFoundation/slang.git" - }, - "bugs": "https://github.com/NomicFoundation/slang/issues/", - "contributors": [ - { - "name": "Nomic Foundation", - "email": "packages@nomic.foundation" - }, - { - "name": "Antony Blakey", - "email": "antony@nomic.foundation" - }, - { - "name": "Igor Matuszewski", - "email": "igor@nomic.foundation" - }, - { - "name": "Omar Tawfik", - "email": "omar@nomic.foundation" - } - ], - "main": "index.win32-x64-msvc.node", - "files": [ - "index.win32-x64-msvc.node", - "README.md" - ], - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "keywords": [ - "blockchain", - "compilers", - "dapps", - "ethereum", - "parsing", - "smart-contracts", - "solidity", - "tooling" - ] -} diff --git a/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts b/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts similarity index 84% rename from crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts rename to crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts index 35ac4bb910..515826b73b 100644 --- a/crates/solidity/outputs/npm/package/src/generated/ast/generated/ast_types.ts +++ b/crates/solidity/outputs/npm/package/src/generated/ast/generated/nodes.mts @@ -1,8 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -import * as assert from "node:assert"; -import { ast_internal } from "../../napi-bindings/generated"; -import { NodeType, NonterminalKind, NonterminalNode, TerminalNode } from "../../cst"; +import * as generated from "../../../../wasm/index.mjs"; +import { NonterminalKind, NonterminalNode, TerminalNode } from "../../cst/index.mjs"; /* * Sequences: @@ -10,7 +9,7 @@ import { NodeType, NonterminalKind, NonterminalNode, TerminalNode } from "../../ export class SourceUnit { private readonly fetch = once(() => { - const [$members] = ast_internal.selectSequence(this.cst); + const [$members] = generated.ast.Selectors.sequence(this.cst); return { members: new SourceUnitMembers($members as NonterminalNode), @@ -28,7 +27,7 @@ export class SourceUnit { export class PragmaDirective { private readonly fetch = once(() => { - const [$pragmaKeyword, $pragma, $semicolon] = ast_internal.selectSequence(this.cst); + const [$pragmaKeyword, $pragma, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { pragmaKeyword: $pragmaKeyword as TerminalNode, @@ -54,9 +53,9 @@ export class PragmaDirective { } } -export class ABICoderPragma { +export class AbicoderPragma { private readonly fetch = once(() => { - const [$abicoderKeyword, $version] = ast_internal.selectSequence(this.cst); + const [$abicoderKeyword, $version] = generated.ast.Selectors.sequence(this.cst); return { abicoderKeyword: $abicoderKeyword as TerminalNode, @@ -65,7 +64,7 @@ export class ABICoderPragma { }); public constructor(public readonly cst: NonterminalNode) { - assertKind(this.cst.kind, NonterminalKind.ABICoderPragma); + assertKind(this.cst.kind, NonterminalKind.AbicoderPragma); } public get abicoderKeyword(): TerminalNode { @@ -79,7 +78,7 @@ export class ABICoderPragma { export class ExperimentalPragma { private readonly fetch = once(() => { - const [$experimentalKeyword, $feature] = ast_internal.selectSequence(this.cst); + const [$experimentalKeyword, $feature] = generated.ast.Selectors.sequence(this.cst); return { experimentalKeyword: $experimentalKeyword as TerminalNode, @@ -102,7 +101,7 @@ export class ExperimentalPragma { export class VersionPragma { private readonly fetch = once(() => { - const [$solidityKeyword, $sets] = ast_internal.selectSequence(this.cst); + const [$solidityKeyword, $sets] = generated.ast.Selectors.sequence(this.cst); return { solidityKeyword: $solidityKeyword as TerminalNode, @@ -125,7 +124,7 @@ export class VersionPragma { export class VersionRange { private readonly fetch = once(() => { - const [$start, $minus, $end] = ast_internal.selectSequence(this.cst); + const [$start, $minus, $end] = generated.ast.Selectors.sequence(this.cst); return { start: new VersionLiteral($start as NonterminalNode), @@ -153,10 +152,10 @@ export class VersionRange { export class VersionTerm { private readonly fetch = once(() => { - const [$operator, $literal] = ast_internal.selectSequence(this.cst); + const [$operator, $literal] = generated.ast.Selectors.sequence(this.cst); return { - operator: $operator === null ? undefined : new VersionOperator($operator as NonterminalNode), + operator: $operator === undefined ? undefined : new VersionOperator($operator as NonterminalNode), literal: new VersionLiteral($literal as NonterminalNode), }; }); @@ -176,7 +175,7 @@ export class VersionTerm { export class ImportDirective { private readonly fetch = once(() => { - const [$importKeyword, $clause, $semicolon] = ast_internal.selectSequence(this.cst); + const [$importKeyword, $clause, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { importKeyword: $importKeyword as TerminalNode, @@ -204,11 +203,11 @@ export class ImportDirective { export class PathImport { private readonly fetch = once(() => { - const [$path, $alias] = ast_internal.selectSequence(this.cst); + const [$path, $alias] = generated.ast.Selectors.sequence(this.cst); return { path: new StringLiteral($path as NonterminalNode), - alias: $alias === null ? undefined : new ImportAlias($alias as NonterminalNode), + alias: $alias === undefined ? undefined : new ImportAlias($alias as NonterminalNode), }; }); @@ -227,7 +226,7 @@ export class PathImport { export class NamedImport { private readonly fetch = once(() => { - const [$asterisk, $alias, $fromKeyword, $path] = ast_internal.selectSequence(this.cst); + const [$asterisk, $alias, $fromKeyword, $path] = generated.ast.Selectors.sequence(this.cst); return { asterisk: $asterisk as TerminalNode, @@ -260,7 +259,7 @@ export class NamedImport { export class ImportDeconstruction { private readonly fetch = once(() => { - const [$openBrace, $symbols, $closeBrace, $fromKeyword, $path] = ast_internal.selectSequence(this.cst); + const [$openBrace, $symbols, $closeBrace, $fromKeyword, $path] = generated.ast.Selectors.sequence(this.cst); return { openBrace: $openBrace as TerminalNode, @@ -298,11 +297,11 @@ export class ImportDeconstruction { export class ImportDeconstructionSymbol { private readonly fetch = once(() => { - const [$name, $alias] = ast_internal.selectSequence(this.cst); + const [$name, $alias] = generated.ast.Selectors.sequence(this.cst); return { name: $name as TerminalNode, - alias: $alias === null ? undefined : new ImportAlias($alias as NonterminalNode), + alias: $alias === undefined ? undefined : new ImportAlias($alias as NonterminalNode), }; }); @@ -321,7 +320,7 @@ export class ImportDeconstructionSymbol { export class ImportAlias { private readonly fetch = once(() => { - const [$asKeyword, $identifier] = ast_internal.selectSequence(this.cst); + const [$asKeyword, $identifier] = generated.ast.Selectors.sequence(this.cst); return { asKeyword: $asKeyword as TerminalNode, @@ -344,7 +343,7 @@ export class ImportAlias { export class UsingDirective { private readonly fetch = once(() => { - const [$usingKeyword, $clause, $forKeyword, $target, $globalKeyword, $semicolon] = ast_internal.selectSequence( + const [$usingKeyword, $clause, $forKeyword, $target, $globalKeyword, $semicolon] = generated.ast.Selectors.sequence( this.cst, ); @@ -353,7 +352,7 @@ export class UsingDirective { clause: new UsingClause($clause as NonterminalNode), forKeyword: $forKeyword as TerminalNode, target: new UsingTarget($target as NonterminalNode), - globalKeyword: $globalKeyword === null ? undefined : ($globalKeyword as TerminalNode), + globalKeyword: $globalKeyword === undefined ? undefined : ($globalKeyword as TerminalNode), semicolon: $semicolon as TerminalNode, }; }); @@ -389,7 +388,7 @@ export class UsingDirective { export class UsingDeconstruction { private readonly fetch = once(() => { - const [$openBrace, $symbols, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$openBrace, $symbols, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { openBrace: $openBrace as TerminalNode, @@ -417,11 +416,11 @@ export class UsingDeconstruction { export class UsingDeconstructionSymbol { private readonly fetch = once(() => { - const [$name, $alias] = ast_internal.selectSequence(this.cst); + const [$name, $alias] = generated.ast.Selectors.sequence(this.cst); return { name: new IdentifierPath($name as NonterminalNode), - alias: $alias === null ? undefined : new UsingAlias($alias as NonterminalNode), + alias: $alias === undefined ? undefined : new UsingAlias($alias as NonterminalNode), }; }); @@ -440,7 +439,7 @@ export class UsingDeconstructionSymbol { export class UsingAlias { private readonly fetch = once(() => { - const [$asKeyword, $operator] = ast_internal.selectSequence(this.cst); + const [$asKeyword, $operator] = generated.ast.Selectors.sequence(this.cst); return { asKeyword: $asKeyword as TerminalNode, @@ -464,13 +463,13 @@ export class UsingAlias { export class ContractDefinition { private readonly fetch = once(() => { const [$abstractKeyword, $contractKeyword, $name, $inheritance, $openBrace, $members, $closeBrace] = - ast_internal.selectSequence(this.cst); + generated.ast.Selectors.sequence(this.cst); return { - abstractKeyword: $abstractKeyword === null ? undefined : ($abstractKeyword as TerminalNode), + abstractKeyword: $abstractKeyword === undefined ? undefined : ($abstractKeyword as TerminalNode), contractKeyword: $contractKeyword as TerminalNode, name: $name as TerminalNode, - inheritance: $inheritance === null ? undefined : new InheritanceSpecifier($inheritance as NonterminalNode), + inheritance: $inheritance === undefined ? undefined : new InheritanceSpecifier($inheritance as NonterminalNode), openBrace: $openBrace as TerminalNode, members: new ContractMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, @@ -512,7 +511,7 @@ export class ContractDefinition { export class InheritanceSpecifier { private readonly fetch = once(() => { - const [$isKeyword, $types] = ast_internal.selectSequence(this.cst); + const [$isKeyword, $types] = generated.ast.Selectors.sequence(this.cst); return { isKeyword: $isKeyword as TerminalNode, @@ -535,11 +534,11 @@ export class InheritanceSpecifier { export class InheritanceType { private readonly fetch = once(() => { - const [$typeName, $arguments] = ast_internal.selectSequence(this.cst); + const [$typeName, $arguments] = generated.ast.Selectors.sequence(this.cst); return { typeName: new IdentifierPath($typeName as NonterminalNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), + arguments: $arguments === undefined ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), }; }); @@ -558,14 +557,13 @@ export class InheritanceType { export class InterfaceDefinition { private readonly fetch = once(() => { - const [$interfaceKeyword, $name, $inheritance, $openBrace, $members, $closeBrace] = ast_internal.selectSequence( - this.cst, - ); + const [$interfaceKeyword, $name, $inheritance, $openBrace, $members, $closeBrace] = + generated.ast.Selectors.sequence(this.cst); return { interfaceKeyword: $interfaceKeyword as TerminalNode, name: $name as TerminalNode, - inheritance: $inheritance === null ? undefined : new InheritanceSpecifier($inheritance as NonterminalNode), + inheritance: $inheritance === undefined ? undefined : new InheritanceSpecifier($inheritance as NonterminalNode), openBrace: $openBrace as TerminalNode, members: new InterfaceMembers($members as NonterminalNode), closeBrace: $closeBrace as TerminalNode, @@ -603,7 +601,7 @@ export class InterfaceDefinition { export class LibraryDefinition { private readonly fetch = once(() => { - const [$libraryKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$libraryKeyword, $name, $openBrace, $members, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { libraryKeyword: $libraryKeyword as TerminalNode, @@ -641,7 +639,7 @@ export class LibraryDefinition { export class StructDefinition { private readonly fetch = once(() => { - const [$structKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$structKeyword, $name, $openBrace, $members, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { structKeyword: $structKeyword as TerminalNode, @@ -679,7 +677,7 @@ export class StructDefinition { export class StructMember { private readonly fetch = once(() => { - const [$typeName, $name, $semicolon] = ast_internal.selectSequence(this.cst); + const [$typeName, $name, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), @@ -707,7 +705,7 @@ export class StructMember { export class EnumDefinition { private readonly fetch = once(() => { - const [$enumKeyword, $name, $openBrace, $members, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$enumKeyword, $name, $openBrace, $members, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { enumKeyword: $enumKeyword as TerminalNode, @@ -745,7 +743,7 @@ export class EnumDefinition { export class ConstantDefinition { private readonly fetch = once(() => { - const [$typeName, $constantKeyword, $name, $equal, $value, $semicolon] = ast_internal.selectSequence(this.cst); + const [$typeName, $constantKeyword, $name, $equal, $value, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), @@ -788,13 +786,13 @@ export class ConstantDefinition { export class StateVariableDefinition { private readonly fetch = once(() => { - const [$typeName, $attributes, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); + const [$typeName, $attributes, $name, $value, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), attributes: new StateVariableAttributes($attributes as NonterminalNode), name: $name as TerminalNode, - value: $value === null ? undefined : new StateVariableDefinitionValue($value as NonterminalNode), + value: $value === undefined ? undefined : new StateVariableDefinitionValue($value as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); @@ -826,7 +824,7 @@ export class StateVariableDefinition { export class StateVariableDefinitionValue { private readonly fetch = once(() => { - const [$equal, $value] = ast_internal.selectSequence(this.cst); + const [$equal, $value] = generated.ast.Selectors.sequence(this.cst); return { equal: $equal as TerminalNode, @@ -849,14 +847,16 @@ export class StateVariableDefinitionValue { export class FunctionDefinition { private readonly fetch = once(() => { - const [$functionKeyword, $name, $parameters, $attributes, $returns, $body] = ast_internal.selectSequence(this.cst); + const [$functionKeyword, $name, $parameters, $attributes, $returns, $body] = generated.ast.Selectors.sequence( + this.cst, + ); return { functionKeyword: $functionKeyword as TerminalNode, name: new FunctionName($name as NonterminalNode), parameters: new ParametersDeclaration($parameters as NonterminalNode), attributes: new FunctionAttributes($attributes as NonterminalNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonterminalNode), + returns: $returns === undefined ? undefined : new ReturnsDeclaration($returns as NonterminalNode), body: new FunctionBody($body as NonterminalNode), }; }); @@ -892,7 +892,7 @@ export class FunctionDefinition { export class ParametersDeclaration { private readonly fetch = once(() => { - const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $parameters, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -920,12 +920,13 @@ export class ParametersDeclaration { export class Parameter { private readonly fetch = once(() => { - const [$typeName, $storageLocation, $name] = ast_internal.selectSequence(this.cst); + const [$typeName, $storageLocation, $name] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), - name: $name === null ? undefined : ($name as TerminalNode), + storageLocation: + $storageLocation === undefined ? undefined : new StorageLocation($storageLocation as NonterminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), }; }); @@ -948,11 +949,11 @@ export class Parameter { export class OverrideSpecifier { private readonly fetch = once(() => { - const [$overrideKeyword, $overridden] = ast_internal.selectSequence(this.cst); + const [$overrideKeyword, $overridden] = generated.ast.Selectors.sequence(this.cst); return { overrideKeyword: $overrideKeyword as TerminalNode, - overridden: $overridden === null ? undefined : new OverridePathsDeclaration($overridden as NonterminalNode), + overridden: $overridden === undefined ? undefined : new OverridePathsDeclaration($overridden as NonterminalNode), }; }); @@ -971,7 +972,7 @@ export class OverrideSpecifier { export class OverridePathsDeclaration { private readonly fetch = once(() => { - const [$openParen, $paths, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $paths, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -999,7 +1000,7 @@ export class OverridePathsDeclaration { export class ReturnsDeclaration { private readonly fetch = once(() => { - const [$returnsKeyword, $variables] = ast_internal.selectSequence(this.cst); + const [$returnsKeyword, $variables] = generated.ast.Selectors.sequence(this.cst); return { returnsKeyword: $returnsKeyword as TerminalNode, @@ -1022,7 +1023,7 @@ export class ReturnsDeclaration { export class ConstructorDefinition { private readonly fetch = once(() => { - const [$constructorKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); + const [$constructorKeyword, $parameters, $attributes, $body] = generated.ast.Selectors.sequence(this.cst); return { constructorKeyword: $constructorKeyword as TerminalNode, @@ -1055,7 +1056,7 @@ export class ConstructorDefinition { export class UnnamedFunctionDefinition { private readonly fetch = once(() => { - const [$functionKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); + const [$functionKeyword, $parameters, $attributes, $body] = generated.ast.Selectors.sequence(this.cst); return { functionKeyword: $functionKeyword as TerminalNode, @@ -1088,13 +1089,13 @@ export class UnnamedFunctionDefinition { export class FallbackFunctionDefinition { private readonly fetch = once(() => { - const [$fallbackKeyword, $parameters, $attributes, $returns, $body] = ast_internal.selectSequence(this.cst); + const [$fallbackKeyword, $parameters, $attributes, $returns, $body] = generated.ast.Selectors.sequence(this.cst); return { fallbackKeyword: $fallbackKeyword as TerminalNode, parameters: new ParametersDeclaration($parameters as NonterminalNode), attributes: new FallbackFunctionAttributes($attributes as NonterminalNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonterminalNode), + returns: $returns === undefined ? undefined : new ReturnsDeclaration($returns as NonterminalNode), body: new FunctionBody($body as NonterminalNode), }; }); @@ -1126,7 +1127,7 @@ export class FallbackFunctionDefinition { export class ReceiveFunctionDefinition { private readonly fetch = once(() => { - const [$receiveKeyword, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); + const [$receiveKeyword, $parameters, $attributes, $body] = generated.ast.Selectors.sequence(this.cst); return { receiveKeyword: $receiveKeyword as TerminalNode, @@ -1159,12 +1160,12 @@ export class ReceiveFunctionDefinition { export class ModifierDefinition { private readonly fetch = once(() => { - const [$modifierKeyword, $name, $parameters, $attributes, $body] = ast_internal.selectSequence(this.cst); + const [$modifierKeyword, $name, $parameters, $attributes, $body] = generated.ast.Selectors.sequence(this.cst); return { modifierKeyword: $modifierKeyword as TerminalNode, name: $name as TerminalNode, - parameters: $parameters === null ? undefined : new ParametersDeclaration($parameters as NonterminalNode), + parameters: $parameters === undefined ? undefined : new ParametersDeclaration($parameters as NonterminalNode), attributes: new ModifierAttributes($attributes as NonterminalNode), body: new FunctionBody($body as NonterminalNode), }; @@ -1197,11 +1198,11 @@ export class ModifierDefinition { export class ModifierInvocation { private readonly fetch = once(() => { - const [$name, $arguments] = ast_internal.selectSequence(this.cst); + const [$name, $arguments] = generated.ast.Selectors.sequence(this.cst); return { name: new IdentifierPath($name as NonterminalNode), - arguments: $arguments === null ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), + arguments: $arguments === undefined ? undefined : new ArgumentsDeclaration($arguments as NonterminalNode), }; }); @@ -1220,13 +1221,15 @@ export class ModifierInvocation { export class EventDefinition { private readonly fetch = once(() => { - const [$eventKeyword, $name, $parameters, $anonymousKeyword, $semicolon] = ast_internal.selectSequence(this.cst); + const [$eventKeyword, $name, $parameters, $anonymousKeyword, $semicolon] = generated.ast.Selectors.sequence( + this.cst, + ); return { eventKeyword: $eventKeyword as TerminalNode, name: $name as TerminalNode, parameters: new EventParametersDeclaration($parameters as NonterminalNode), - anonymousKeyword: $anonymousKeyword === null ? undefined : ($anonymousKeyword as TerminalNode), + anonymousKeyword: $anonymousKeyword === undefined ? undefined : ($anonymousKeyword as TerminalNode), semicolon: $semicolon as TerminalNode, }; }); @@ -1258,7 +1261,7 @@ export class EventDefinition { export class EventParametersDeclaration { private readonly fetch = once(() => { - const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $parameters, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -1286,12 +1289,12 @@ export class EventParametersDeclaration { export class EventParameter { private readonly fetch = once(() => { - const [$typeName, $indexedKeyword, $name] = ast_internal.selectSequence(this.cst); + const [$typeName, $indexedKeyword, $name] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), - indexedKeyword: $indexedKeyword === null ? undefined : ($indexedKeyword as TerminalNode), - name: $name === null ? undefined : ($name as TerminalNode), + indexedKeyword: $indexedKeyword === undefined ? undefined : ($indexedKeyword as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), }; }); @@ -1314,7 +1317,7 @@ export class EventParameter { export class UserDefinedValueTypeDefinition { private readonly fetch = once(() => { - const [$typeKeyword, $name, $isKeyword, $valueType, $semicolon] = ast_internal.selectSequence(this.cst); + const [$typeKeyword, $name, $isKeyword, $valueType, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { typeKeyword: $typeKeyword as TerminalNode, @@ -1352,7 +1355,7 @@ export class UserDefinedValueTypeDefinition { export class ErrorDefinition { private readonly fetch = once(() => { - const [$errorKeyword, $name, $members, $semicolon] = ast_internal.selectSequence(this.cst); + const [$errorKeyword, $name, $members, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { errorKeyword: $errorKeyword as TerminalNode, @@ -1385,7 +1388,7 @@ export class ErrorDefinition { export class ErrorParametersDeclaration { private readonly fetch = once(() => { - const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $parameters, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -1413,11 +1416,11 @@ export class ErrorParametersDeclaration { export class ErrorParameter { private readonly fetch = once(() => { - const [$typeName, $name] = ast_internal.selectSequence(this.cst); + const [$typeName, $name] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), - name: $name === null ? undefined : ($name as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), }; }); @@ -1436,12 +1439,12 @@ export class ErrorParameter { export class ArrayTypeName { private readonly fetch = once(() => { - const [$operand, $openBracket, $index, $closeBracket] = ast_internal.selectSequence(this.cst); + const [$operand, $openBracket, $index, $closeBracket] = generated.ast.Selectors.sequence(this.cst); return { operand: new TypeName($operand as NonterminalNode), openBracket: $openBracket as TerminalNode, - index: $index === null ? undefined : new Expression($index as NonterminalNode), + index: $index === undefined ? undefined : new Expression($index as NonterminalNode), closeBracket: $closeBracket as TerminalNode, }; }); @@ -1469,13 +1472,13 @@ export class ArrayTypeName { export class FunctionType { private readonly fetch = once(() => { - const [$functionKeyword, $parameters, $attributes, $returns] = ast_internal.selectSequence(this.cst); + const [$functionKeyword, $parameters, $attributes, $returns] = generated.ast.Selectors.sequence(this.cst); return { functionKeyword: $functionKeyword as TerminalNode, parameters: new ParametersDeclaration($parameters as NonterminalNode), attributes: new FunctionTypeAttributes($attributes as NonterminalNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonterminalNode), + returns: $returns === undefined ? undefined : new ReturnsDeclaration($returns as NonterminalNode), }; }); @@ -1503,7 +1506,7 @@ export class FunctionType { export class MappingType { private readonly fetch = once(() => { const [$mappingKeyword, $openParen, $keyType, $equalGreaterThan, $valueType, $closeParen] = - ast_internal.selectSequence(this.cst); + generated.ast.Selectors.sequence(this.cst); return { mappingKeyword: $mappingKeyword as TerminalNode, @@ -1546,11 +1549,11 @@ export class MappingType { export class MappingKey { private readonly fetch = once(() => { - const [$keyType, $name] = ast_internal.selectSequence(this.cst); + const [$keyType, $name] = generated.ast.Selectors.sequence(this.cst); return { keyType: new MappingKeyType($keyType as NonterminalNode), - name: $name === null ? undefined : ($name as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), }; }); @@ -1569,11 +1572,11 @@ export class MappingKey { export class MappingValue { private readonly fetch = once(() => { - const [$typeName, $name] = ast_internal.selectSequence(this.cst); + const [$typeName, $name] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), - name: $name === null ? undefined : ($name as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), }; }); @@ -1592,11 +1595,11 @@ export class MappingValue { export class AddressType { private readonly fetch = once(() => { - const [$addressKeyword, $payableKeyword] = ast_internal.selectSequence(this.cst); + const [$addressKeyword, $payableKeyword] = generated.ast.Selectors.sequence(this.cst); return { addressKeyword: $addressKeyword as TerminalNode, - payableKeyword: $payableKeyword === null ? undefined : ($payableKeyword as TerminalNode), + payableKeyword: $payableKeyword === undefined ? undefined : ($payableKeyword as TerminalNode), }; }); @@ -1615,7 +1618,7 @@ export class AddressType { export class Block { private readonly fetch = once(() => { - const [$openBrace, $statements, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$openBrace, $statements, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { openBrace: $openBrace as TerminalNode, @@ -1643,7 +1646,7 @@ export class Block { export class UncheckedBlock { private readonly fetch = once(() => { - const [$uncheckedKeyword, $block] = ast_internal.selectSequence(this.cst); + const [$uncheckedKeyword, $block] = generated.ast.Selectors.sequence(this.cst); return { uncheckedKeyword: $uncheckedKeyword as TerminalNode, @@ -1666,7 +1669,7 @@ export class UncheckedBlock { export class ExpressionStatement { private readonly fetch = once(() => { - const [$expression, $semicolon] = ast_internal.selectSequence(this.cst); + const [$expression, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { expression: new Expression($expression as NonterminalNode), @@ -1689,12 +1692,12 @@ export class ExpressionStatement { export class AssemblyStatement { private readonly fetch = once(() => { - const [$assemblyKeyword, $label, $flags, $body] = ast_internal.selectSequence(this.cst); + const [$assemblyKeyword, $label, $flags, $body] = generated.ast.Selectors.sequence(this.cst); return { assemblyKeyword: $assemblyKeyword as TerminalNode, - label: $label === null ? undefined : new StringLiteral($label as NonterminalNode), - flags: $flags === null ? undefined : new AssemblyFlagsDeclaration($flags as NonterminalNode), + label: $label === undefined ? undefined : new StringLiteral($label as NonterminalNode), + flags: $flags === undefined ? undefined : new AssemblyFlagsDeclaration($flags as NonterminalNode), body: new YulBlock($body as NonterminalNode), }; }); @@ -1722,7 +1725,7 @@ export class AssemblyStatement { export class AssemblyFlagsDeclaration { private readonly fetch = once(() => { - const [$openParen, $flags, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $flags, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -1751,10 +1754,10 @@ export class AssemblyFlagsDeclaration { export class TupleDeconstructionStatement { private readonly fetch = once(() => { const [$varKeyword, $openParen, $elements, $closeParen, $equal, $expression, $semicolon] = - ast_internal.selectSequence(this.cst); + generated.ast.Selectors.sequence(this.cst); return { - varKeyword: $varKeyword === null ? undefined : ($varKeyword as TerminalNode), + varKeyword: $varKeyword === undefined ? undefined : ($varKeyword as TerminalNode), openParen: $openParen as TerminalNode, elements: new TupleDeconstructionElements($elements as NonterminalNode), closeParen: $closeParen as TerminalNode, @@ -1799,10 +1802,10 @@ export class TupleDeconstructionStatement { export class TupleDeconstructionElement { private readonly fetch = once(() => { - const [$member] = ast_internal.selectSequence(this.cst); + const [$member] = generated.ast.Selectors.sequence(this.cst); return { - member: $member === null ? undefined : new TupleMember($member as NonterminalNode), + member: $member === undefined ? undefined : new TupleMember($member as NonterminalNode), }; }); @@ -1817,11 +1820,12 @@ export class TupleDeconstructionElement { export class TypedTupleMember { private readonly fetch = once(() => { - const [$typeName, $storageLocation, $name] = ast_internal.selectSequence(this.cst); + const [$typeName, $storageLocation, $name] = generated.ast.Selectors.sequence(this.cst); return { typeName: new TypeName($typeName as NonterminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), + storageLocation: + $storageLocation === undefined ? undefined : new StorageLocation($storageLocation as NonterminalNode), name: $name as TerminalNode, }; }); @@ -1845,10 +1849,11 @@ export class TypedTupleMember { export class UntypedTupleMember { private readonly fetch = once(() => { - const [$storageLocation, $name] = ast_internal.selectSequence(this.cst); + const [$storageLocation, $name] = generated.ast.Selectors.sequence(this.cst); return { - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), + storageLocation: + $storageLocation === undefined ? undefined : new StorageLocation($storageLocation as NonterminalNode), name: $name as TerminalNode, }; }); @@ -1868,13 +1873,14 @@ export class UntypedTupleMember { export class VariableDeclarationStatement { private readonly fetch = once(() => { - const [$variableType, $storageLocation, $name, $value, $semicolon] = ast_internal.selectSequence(this.cst); + const [$variableType, $storageLocation, $name, $value, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { variableType: new VariableDeclarationType($variableType as NonterminalNode), - storageLocation: $storageLocation === null ? undefined : new StorageLocation($storageLocation as NonterminalNode), + storageLocation: + $storageLocation === undefined ? undefined : new StorageLocation($storageLocation as NonterminalNode), name: $name as TerminalNode, - value: $value === null ? undefined : new VariableDeclarationValue($value as NonterminalNode), + value: $value === undefined ? undefined : new VariableDeclarationValue($value as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); @@ -1906,7 +1912,7 @@ export class VariableDeclarationStatement { export class VariableDeclarationValue { private readonly fetch = once(() => { - const [$equal, $expression] = ast_internal.selectSequence(this.cst); + const [$equal, $expression] = generated.ast.Selectors.sequence(this.cst); return { equal: $equal as TerminalNode, @@ -1929,7 +1935,9 @@ export class VariableDeclarationValue { export class IfStatement { private readonly fetch = once(() => { - const [$ifKeyword, $openParen, $condition, $closeParen, $body, $elseBranch] = ast_internal.selectSequence(this.cst); + const [$ifKeyword, $openParen, $condition, $closeParen, $body, $elseBranch] = generated.ast.Selectors.sequence( + this.cst, + ); return { ifKeyword: $ifKeyword as TerminalNode, @@ -1937,7 +1945,7 @@ export class IfStatement { condition: new Expression($condition as NonterminalNode), closeParen: $closeParen as TerminalNode, body: new Statement($body as NonterminalNode), - elseBranch: $elseBranch === null ? undefined : new ElseBranch($elseBranch as NonterminalNode), + elseBranch: $elseBranch === undefined ? undefined : new ElseBranch($elseBranch as NonterminalNode), }; }); @@ -1972,7 +1980,7 @@ export class IfStatement { export class ElseBranch { private readonly fetch = once(() => { - const [$elseKeyword, $body] = ast_internal.selectSequence(this.cst); + const [$elseKeyword, $body] = generated.ast.Selectors.sequence(this.cst); return { elseKeyword: $elseKeyword as TerminalNode, @@ -1996,14 +2004,14 @@ export class ElseBranch { export class ForStatement { private readonly fetch = once(() => { const [$forKeyword, $openParen, $initialization, $condition, $iterator, $closeParen, $body] = - ast_internal.selectSequence(this.cst); + generated.ast.Selectors.sequence(this.cst); return { forKeyword: $forKeyword as TerminalNode, openParen: $openParen as TerminalNode, initialization: new ForStatementInitialization($initialization as NonterminalNode), condition: new ForStatementCondition($condition as NonterminalNode), - iterator: $iterator === null ? undefined : new Expression($iterator as NonterminalNode), + iterator: $iterator === undefined ? undefined : new Expression($iterator as NonterminalNode), closeParen: $closeParen as TerminalNode, body: new Statement($body as NonterminalNode), }; @@ -2044,7 +2052,7 @@ export class ForStatement { export class WhileStatement { private readonly fetch = once(() => { - const [$whileKeyword, $openParen, $condition, $closeParen, $body] = ast_internal.selectSequence(this.cst); + const [$whileKeyword, $openParen, $condition, $closeParen, $body] = generated.ast.Selectors.sequence(this.cst); return { whileKeyword: $whileKeyword as TerminalNode, @@ -2083,7 +2091,7 @@ export class WhileStatement { export class DoWhileStatement { private readonly fetch = once(() => { const [$doKeyword, $body, $whileKeyword, $openParen, $condition, $closeParen, $semicolon] = - ast_internal.selectSequence(this.cst); + generated.ast.Selectors.sequence(this.cst); return { doKeyword: $doKeyword as TerminalNode, @@ -2131,7 +2139,7 @@ export class DoWhileStatement { export class ContinueStatement { private readonly fetch = once(() => { - const [$continueKeyword, $semicolon] = ast_internal.selectSequence(this.cst); + const [$continueKeyword, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { continueKeyword: $continueKeyword as TerminalNode, @@ -2154,7 +2162,7 @@ export class ContinueStatement { export class BreakStatement { private readonly fetch = once(() => { - const [$breakKeyword, $semicolon] = ast_internal.selectSequence(this.cst); + const [$breakKeyword, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { breakKeyword: $breakKeyword as TerminalNode, @@ -2177,11 +2185,11 @@ export class BreakStatement { export class ReturnStatement { private readonly fetch = once(() => { - const [$returnKeyword, $expression, $semicolon] = ast_internal.selectSequence(this.cst); + const [$returnKeyword, $expression, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { returnKeyword: $returnKeyword as TerminalNode, - expression: $expression === null ? undefined : new Expression($expression as NonterminalNode), + expression: $expression === undefined ? undefined : new Expression($expression as NonterminalNode), semicolon: $semicolon as TerminalNode, }; }); @@ -2205,7 +2213,7 @@ export class ReturnStatement { export class EmitStatement { private readonly fetch = once(() => { - const [$emitKeyword, $event, $arguments, $semicolon] = ast_internal.selectSequence(this.cst); + const [$emitKeyword, $event, $arguments, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { emitKeyword: $emitKeyword as TerminalNode, @@ -2238,12 +2246,12 @@ export class EmitStatement { export class TryStatement { private readonly fetch = once(() => { - const [$tryKeyword, $expression, $returns, $body, $catchClauses] = ast_internal.selectSequence(this.cst); + const [$tryKeyword, $expression, $returns, $body, $catchClauses] = generated.ast.Selectors.sequence(this.cst); return { tryKeyword: $tryKeyword as TerminalNode, expression: new Expression($expression as NonterminalNode), - returns: $returns === null ? undefined : new ReturnsDeclaration($returns as NonterminalNode), + returns: $returns === undefined ? undefined : new ReturnsDeclaration($returns as NonterminalNode), body: new Block($body as NonterminalNode), catchClauses: new CatchClauses($catchClauses as NonterminalNode), }; @@ -2276,11 +2284,11 @@ export class TryStatement { export class CatchClause { private readonly fetch = once(() => { - const [$catchKeyword, $error, $body] = ast_internal.selectSequence(this.cst); + const [$catchKeyword, $error, $body] = generated.ast.Selectors.sequence(this.cst); return { catchKeyword: $catchKeyword as TerminalNode, - error: $error === null ? undefined : new CatchClauseError($error as NonterminalNode), + error: $error === undefined ? undefined : new CatchClauseError($error as NonterminalNode), body: new Block($body as NonterminalNode), }; }); @@ -2304,10 +2312,10 @@ export class CatchClause { export class CatchClauseError { private readonly fetch = once(() => { - const [$name, $parameters] = ast_internal.selectSequence(this.cst); + const [$name, $parameters] = generated.ast.Selectors.sequence(this.cst); return { - name: $name === null ? undefined : ($name as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), parameters: new ParametersDeclaration($parameters as NonterminalNode), }; }); @@ -2327,11 +2335,11 @@ export class CatchClauseError { export class RevertStatement { private readonly fetch = once(() => { - const [$revertKeyword, $error, $arguments, $semicolon] = ast_internal.selectSequence(this.cst); + const [$revertKeyword, $error, $arguments, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { revertKeyword: $revertKeyword as TerminalNode, - error: $error === null ? undefined : new IdentifierPath($error as NonterminalNode), + error: $error === undefined ? undefined : new IdentifierPath($error as NonterminalNode), arguments: new ArgumentsDeclaration($arguments as NonterminalNode), semicolon: $semicolon as TerminalNode, }; @@ -2360,7 +2368,7 @@ export class RevertStatement { export class ThrowStatement { private readonly fetch = once(() => { - const [$throwKeyword, $semicolon] = ast_internal.selectSequence(this.cst); + const [$throwKeyword, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { throwKeyword: $throwKeyword as TerminalNode, @@ -2383,7 +2391,7 @@ export class ThrowStatement { export class AssignmentExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2411,7 +2419,9 @@ export class AssignmentExpression { export class ConditionalExpression { private readonly fetch = once(() => { - const [$operand, $questionMark, $trueExpression, $colon, $falseExpression] = ast_internal.selectSequence(this.cst); + const [$operand, $questionMark, $trueExpression, $colon, $falseExpression] = generated.ast.Selectors.sequence( + this.cst, + ); return { operand: new Expression($operand as NonterminalNode), @@ -2449,7 +2459,7 @@ export class ConditionalExpression { export class OrExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2477,7 +2487,7 @@ export class OrExpression { export class AndExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2505,7 +2515,7 @@ export class AndExpression { export class EqualityExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2533,7 +2543,7 @@ export class EqualityExpression { export class ComparisonExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2561,7 +2571,7 @@ export class ComparisonExpression { export class BitwiseOrExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2589,7 +2599,7 @@ export class BitwiseOrExpression { export class BitwiseXorExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2617,7 +2627,7 @@ export class BitwiseXorExpression { export class BitwiseAndExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2645,7 +2655,7 @@ export class BitwiseAndExpression { export class ShiftExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2673,7 +2683,7 @@ export class ShiftExpression { export class AdditiveExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2701,7 +2711,7 @@ export class AdditiveExpression { export class MultiplicativeExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2729,7 +2739,7 @@ export class MultiplicativeExpression { export class ExponentiationExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -2757,7 +2767,7 @@ export class ExponentiationExpression { export class PostfixExpression { private readonly fetch = once(() => { - const [$operand, $operator] = ast_internal.selectSequence(this.cst); + const [$operand, $operator] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), @@ -2780,7 +2790,7 @@ export class PostfixExpression { export class PrefixExpression { private readonly fetch = once(() => { - const [$operator, $operand] = ast_internal.selectSequence(this.cst); + const [$operator, $operand] = generated.ast.Selectors.sequence(this.cst); return { operator: $operator as TerminalNode, @@ -2803,7 +2813,7 @@ export class PrefixExpression { export class FunctionCallExpression { private readonly fetch = once(() => { - const [$operand, $arguments] = ast_internal.selectSequence(this.cst); + const [$operand, $arguments] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), @@ -2826,7 +2836,7 @@ export class FunctionCallExpression { export class CallOptionsExpression { private readonly fetch = once(() => { - const [$operand, $openBrace, $options, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$operand, $openBrace, $options, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), @@ -2859,7 +2869,7 @@ export class CallOptionsExpression { export class MemberAccessExpression { private readonly fetch = once(() => { - const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); + const [$operand, $period, $member] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), @@ -2887,13 +2897,13 @@ export class MemberAccessExpression { export class IndexAccessExpression { private readonly fetch = once(() => { - const [$operand, $openBracket, $start, $end, $closeBracket] = ast_internal.selectSequence(this.cst); + const [$operand, $openBracket, $start, $end, $closeBracket] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), openBracket: $openBracket as TerminalNode, - start: $start === null ? undefined : new Expression($start as NonterminalNode), - end: $end === null ? undefined : new IndexAccessEnd($end as NonterminalNode), + start: $start === undefined ? undefined : new Expression($start as NonterminalNode), + end: $end === undefined ? undefined : new IndexAccessEnd($end as NonterminalNode), closeBracket: $closeBracket as TerminalNode, }; }); @@ -2925,11 +2935,11 @@ export class IndexAccessExpression { export class IndexAccessEnd { private readonly fetch = once(() => { - const [$colon, $end] = ast_internal.selectSequence(this.cst); + const [$colon, $end] = generated.ast.Selectors.sequence(this.cst); return { colon: $colon as TerminalNode, - end: $end === null ? undefined : new Expression($end as NonterminalNode), + end: $end === undefined ? undefined : new Expression($end as NonterminalNode), }; }); @@ -2948,7 +2958,7 @@ export class IndexAccessEnd { export class PositionalArgumentsDeclaration { private readonly fetch = once(() => { - const [$openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $arguments, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -2976,11 +2986,11 @@ export class PositionalArgumentsDeclaration { export class NamedArgumentsDeclaration { private readonly fetch = once(() => { - const [$openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $arguments, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, - arguments: $arguments === null ? undefined : new NamedArgumentGroup($arguments as NonterminalNode), + arguments: $arguments === undefined ? undefined : new NamedArgumentGroup($arguments as NonterminalNode), closeParen: $closeParen as TerminalNode, }; }); @@ -3004,7 +3014,7 @@ export class NamedArgumentsDeclaration { export class NamedArgumentGroup { private readonly fetch = once(() => { - const [$openBrace, $arguments, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$openBrace, $arguments, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { openBrace: $openBrace as TerminalNode, @@ -3032,7 +3042,7 @@ export class NamedArgumentGroup { export class NamedArgument { private readonly fetch = once(() => { - const [$name, $colon, $value] = ast_internal.selectSequence(this.cst); + const [$name, $colon, $value] = generated.ast.Selectors.sequence(this.cst); return { name: $name as TerminalNode, @@ -3060,7 +3070,7 @@ export class NamedArgument { export class TypeExpression { private readonly fetch = once(() => { - const [$typeKeyword, $openParen, $typeName, $closeParen] = ast_internal.selectSequence(this.cst); + const [$typeKeyword, $openParen, $typeName, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { typeKeyword: $typeKeyword as TerminalNode, @@ -3093,7 +3103,7 @@ export class TypeExpression { export class NewExpression { private readonly fetch = once(() => { - const [$newKeyword, $typeName] = ast_internal.selectSequence(this.cst); + const [$newKeyword, $typeName] = generated.ast.Selectors.sequence(this.cst); return { newKeyword: $newKeyword as TerminalNode, @@ -3116,7 +3126,7 @@ export class NewExpression { export class TupleExpression { private readonly fetch = once(() => { - const [$openParen, $items, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $items, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -3144,10 +3154,10 @@ export class TupleExpression { export class TupleValue { private readonly fetch = once(() => { - const [$expression] = ast_internal.selectSequence(this.cst); + const [$expression] = generated.ast.Selectors.sequence(this.cst); return { - expression: $expression === null ? undefined : new Expression($expression as NonterminalNode), + expression: $expression === undefined ? undefined : new Expression($expression as NonterminalNode), }; }); @@ -3162,7 +3172,7 @@ export class TupleValue { export class ArrayExpression { private readonly fetch = once(() => { - const [$openBracket, $items, $closeBracket] = ast_internal.selectSequence(this.cst); + const [$openBracket, $items, $closeBracket] = generated.ast.Selectors.sequence(this.cst); return { openBracket: $openBracket as TerminalNode, @@ -3190,11 +3200,11 @@ export class ArrayExpression { export class HexNumberExpression { private readonly fetch = once(() => { - const [$literal, $unit] = ast_internal.selectSequence(this.cst); + const [$literal, $unit] = generated.ast.Selectors.sequence(this.cst); return { literal: $literal as TerminalNode, - unit: $unit === null ? undefined : new NumberUnit($unit as NonterminalNode), + unit: $unit === undefined ? undefined : new NumberUnit($unit as NonterminalNode), }; }); @@ -3213,11 +3223,11 @@ export class HexNumberExpression { export class DecimalNumberExpression { private readonly fetch = once(() => { - const [$literal, $unit] = ast_internal.selectSequence(this.cst); + const [$literal, $unit] = generated.ast.Selectors.sequence(this.cst); return { literal: $literal as TerminalNode, - unit: $unit === null ? undefined : new NumberUnit($unit as NonterminalNode), + unit: $unit === undefined ? undefined : new NumberUnit($unit as NonterminalNode), }; }); @@ -3236,7 +3246,7 @@ export class DecimalNumberExpression { export class YulBlock { private readonly fetch = once(() => { - const [$openBrace, $statements, $closeBrace] = ast_internal.selectSequence(this.cst); + const [$openBrace, $statements, $closeBrace] = generated.ast.Selectors.sequence(this.cst); return { openBrace: $openBrace as TerminalNode, @@ -3264,13 +3274,13 @@ export class YulBlock { export class YulFunctionDefinition { private readonly fetch = once(() => { - const [$functionKeyword, $name, $parameters, $returns, $body] = ast_internal.selectSequence(this.cst); + const [$functionKeyword, $name, $parameters, $returns, $body] = generated.ast.Selectors.sequence(this.cst); return { functionKeyword: $functionKeyword as TerminalNode, name: $name as TerminalNode, parameters: new YulParametersDeclaration($parameters as NonterminalNode), - returns: $returns === null ? undefined : new YulReturnsDeclaration($returns as NonterminalNode), + returns: $returns === undefined ? undefined : new YulReturnsDeclaration($returns as NonterminalNode), body: new YulBlock($body as NonterminalNode), }; }); @@ -3302,7 +3312,7 @@ export class YulFunctionDefinition { export class YulParametersDeclaration { private readonly fetch = once(() => { - const [$openParen, $parameters, $closeParen] = ast_internal.selectSequence(this.cst); + const [$openParen, $parameters, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { openParen: $openParen as TerminalNode, @@ -3330,7 +3340,7 @@ export class YulParametersDeclaration { export class YulReturnsDeclaration { private readonly fetch = once(() => { - const [$minusGreaterThan, $variables] = ast_internal.selectSequence(this.cst); + const [$minusGreaterThan, $variables] = generated.ast.Selectors.sequence(this.cst); return { minusGreaterThan: $minusGreaterThan as TerminalNode, @@ -3353,12 +3363,12 @@ export class YulReturnsDeclaration { export class YulVariableDeclarationStatement { private readonly fetch = once(() => { - const [$letKeyword, $variables, $value] = ast_internal.selectSequence(this.cst); + const [$letKeyword, $variables, $value] = generated.ast.Selectors.sequence(this.cst); return { letKeyword: $letKeyword as TerminalNode, variables: new YulVariableNames($variables as NonterminalNode), - value: $value === null ? undefined : new YulVariableDeclarationValue($value as NonterminalNode), + value: $value === undefined ? undefined : new YulVariableDeclarationValue($value as NonterminalNode), }; }); @@ -3381,7 +3391,7 @@ export class YulVariableDeclarationStatement { export class YulVariableDeclarationValue { private readonly fetch = once(() => { - const [$assignment, $expression] = ast_internal.selectSequence(this.cst); + const [$assignment, $expression] = generated.ast.Selectors.sequence(this.cst); return { assignment: new YulAssignmentOperator($assignment as NonterminalNode), @@ -3404,7 +3414,7 @@ export class YulVariableDeclarationValue { export class YulVariableAssignmentStatement { private readonly fetch = once(() => { - const [$variables, $assignment, $expression] = ast_internal.selectSequence(this.cst); + const [$variables, $assignment, $expression] = generated.ast.Selectors.sequence(this.cst); return { variables: new YulPaths($variables as NonterminalNode), @@ -3432,7 +3442,7 @@ export class YulVariableAssignmentStatement { export class YulColonAndEqual { private readonly fetch = once(() => { - const [$colon, $equal] = ast_internal.selectSequence(this.cst); + const [$colon, $equal] = generated.ast.Selectors.sequence(this.cst); return { colon: $colon as TerminalNode, @@ -3455,7 +3465,7 @@ export class YulColonAndEqual { export class YulStackAssignmentStatement { private readonly fetch = once(() => { - const [$assignment, $variable] = ast_internal.selectSequence(this.cst); + const [$assignment, $variable] = generated.ast.Selectors.sequence(this.cst); return { assignment: new YulStackAssignmentOperator($assignment as NonterminalNode), @@ -3478,7 +3488,7 @@ export class YulStackAssignmentStatement { export class YulEqualAndColon { private readonly fetch = once(() => { - const [$equal, $colon] = ast_internal.selectSequence(this.cst); + const [$equal, $colon] = generated.ast.Selectors.sequence(this.cst); return { equal: $equal as TerminalNode, @@ -3501,7 +3511,7 @@ export class YulEqualAndColon { export class YulIfStatement { private readonly fetch = once(() => { - const [$ifKeyword, $condition, $body] = ast_internal.selectSequence(this.cst); + const [$ifKeyword, $condition, $body] = generated.ast.Selectors.sequence(this.cst); return { ifKeyword: $ifKeyword as TerminalNode, @@ -3529,7 +3539,7 @@ export class YulIfStatement { export class YulForStatement { private readonly fetch = once(() => { - const [$forKeyword, $initialization, $condition, $iterator, $body] = ast_internal.selectSequence(this.cst); + const [$forKeyword, $initialization, $condition, $iterator, $body] = generated.ast.Selectors.sequence(this.cst); return { forKeyword: $forKeyword as TerminalNode, @@ -3567,7 +3577,7 @@ export class YulForStatement { export class YulSwitchStatement { private readonly fetch = once(() => { - const [$switchKeyword, $expression, $cases] = ast_internal.selectSequence(this.cst); + const [$switchKeyword, $expression, $cases] = generated.ast.Selectors.sequence(this.cst); return { switchKeyword: $switchKeyword as TerminalNode, @@ -3595,7 +3605,7 @@ export class YulSwitchStatement { export class YulDefaultCase { private readonly fetch = once(() => { - const [$defaultKeyword, $body] = ast_internal.selectSequence(this.cst); + const [$defaultKeyword, $body] = generated.ast.Selectors.sequence(this.cst); return { defaultKeyword: $defaultKeyword as TerminalNode, @@ -3618,7 +3628,7 @@ export class YulDefaultCase { export class YulValueCase { private readonly fetch = once(() => { - const [$caseKeyword, $value, $body] = ast_internal.selectSequence(this.cst); + const [$caseKeyword, $value, $body] = generated.ast.Selectors.sequence(this.cst); return { caseKeyword: $caseKeyword as TerminalNode, @@ -3646,7 +3656,7 @@ export class YulValueCase { export class YulLeaveStatement { private readonly fetch = once(() => { - const [$leaveKeyword] = ast_internal.selectSequence(this.cst); + const [$leaveKeyword] = generated.ast.Selectors.sequence(this.cst); return { leaveKeyword: $leaveKeyword as TerminalNode, @@ -3664,7 +3674,7 @@ export class YulLeaveStatement { export class YulBreakStatement { private readonly fetch = once(() => { - const [$breakKeyword] = ast_internal.selectSequence(this.cst); + const [$breakKeyword] = generated.ast.Selectors.sequence(this.cst); return { breakKeyword: $breakKeyword as TerminalNode, @@ -3682,7 +3692,7 @@ export class YulBreakStatement { export class YulContinueStatement { private readonly fetch = once(() => { - const [$continueKeyword] = ast_internal.selectSequence(this.cst); + const [$continueKeyword] = generated.ast.Selectors.sequence(this.cst); return { continueKeyword: $continueKeyword as TerminalNode, @@ -3700,7 +3710,7 @@ export class YulContinueStatement { export class YulLabel { private readonly fetch = once(() => { - const [$label, $colon] = ast_internal.selectSequence(this.cst); + const [$label, $colon] = generated.ast.Selectors.sequence(this.cst); return { label: $label as TerminalNode, @@ -3723,7 +3733,7 @@ export class YulLabel { export class YulFunctionCallExpression { private readonly fetch = once(() => { - const [$operand, $openParen, $arguments, $closeParen] = ast_internal.selectSequence(this.cst); + const [$operand, $openParen, $arguments, $closeParen] = generated.ast.Selectors.sequence(this.cst); return { operand: new YulExpression($operand as NonterminalNode), @@ -3773,7 +3783,7 @@ export class SourceUnitMember { | UsingDirective | EventDefinition | ConstantDefinition = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.PragmaDirective: @@ -3804,7 +3814,7 @@ export class SourceUnitMember { return new ConstantDefinition(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3831,19 +3841,19 @@ export class SourceUnitMember { } export class Pragma { - private readonly fetch: () => ABICoderPragma | ExperimentalPragma | VersionPragma = once(() => { - const variant = ast_internal.selectChoice(this.cst); + private readonly fetch: () => AbicoderPragma | ExperimentalPragma | VersionPragma = once(() => { + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { - case NonterminalKind.ABICoderPragma: - return new ABICoderPragma(variant as NonterminalNode); + case NonterminalKind.AbicoderPragma: + return new AbicoderPragma(variant as NonterminalNode); case NonterminalKind.ExperimentalPragma: return new ExperimentalPragma(variant as NonterminalNode); case NonterminalKind.VersionPragma: return new VersionPragma(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3851,17 +3861,17 @@ export class Pragma { assertKind(this.cst.kind, NonterminalKind.Pragma); } - public get variant(): ABICoderPragma | ExperimentalPragma | VersionPragma { + public get variant(): AbicoderPragma | ExperimentalPragma | VersionPragma { return this.fetch(); } } export class ExperimentalFeature { private readonly fetch: () => StringLiteral | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -3869,7 +3879,7 @@ export class ExperimentalFeature { return new StringLiteral(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3884,7 +3894,7 @@ export class ExperimentalFeature { export class VersionExpression { private readonly fetch: () => VersionRange | VersionTerm = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.VersionRange: @@ -3893,7 +3903,7 @@ export class VersionExpression { return new VersionTerm(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3908,7 +3918,7 @@ export class VersionExpression { export class VersionOperator { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -3924,10 +3934,10 @@ export class VersionOperator { export class VersionLiteral { private readonly fetch: () => SimpleVersionLiteral | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -3935,7 +3945,7 @@ export class VersionLiteral { return new SimpleVersionLiteral(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3950,7 +3960,7 @@ export class VersionLiteral { export class ImportClause { private readonly fetch: () => PathImport | NamedImport | ImportDeconstruction = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.PathImport: @@ -3961,7 +3971,7 @@ export class ImportClause { return new ImportDeconstruction(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -3976,7 +3986,7 @@ export class ImportClause { export class UsingClause { private readonly fetch: () => IdentifierPath | UsingDeconstruction = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.IdentifierPath: @@ -3985,7 +3995,7 @@ export class UsingClause { return new UsingDeconstruction(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4000,7 +4010,7 @@ export class UsingClause { export class UsingOperator { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4016,10 +4026,10 @@ export class UsingOperator { export class UsingTarget { private readonly fetch: () => TypeName | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4027,7 +4037,7 @@ export class UsingTarget { return new TypeName(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4055,7 +4065,7 @@ export class ContractMember { | ErrorDefinition | UserDefinedValueTypeDefinition | StateVariableDefinition = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.UsingDirective: @@ -4086,7 +4096,7 @@ export class ContractMember { return new StateVariableDefinition(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4114,10 +4124,10 @@ export class ContractMember { export class StateVariableAttribute { private readonly fetch: () => OverrideSpecifier | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4125,7 +4135,7 @@ export class StateVariableAttribute { return new OverrideSpecifier(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4140,7 +4150,7 @@ export class StateVariableAttribute { export class FunctionName { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4156,10 +4166,10 @@ export class FunctionName { export class FunctionAttribute { private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4169,7 +4179,7 @@ export class FunctionAttribute { return new OverrideSpecifier(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4184,10 +4194,10 @@ export class FunctionAttribute { export class FunctionBody { private readonly fetch: () => Block | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4195,7 +4205,7 @@ export class FunctionBody { return new Block(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4210,10 +4220,10 @@ export class FunctionBody { export class ConstructorAttribute { private readonly fetch: () => ModifierInvocation | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4221,7 +4231,7 @@ export class ConstructorAttribute { return new ModifierInvocation(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4236,10 +4246,10 @@ export class ConstructorAttribute { export class UnnamedFunctionAttribute { private readonly fetch: () => ModifierInvocation | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4247,7 +4257,7 @@ export class UnnamedFunctionAttribute { return new ModifierInvocation(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4262,10 +4272,10 @@ export class UnnamedFunctionAttribute { export class FallbackFunctionAttribute { private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4275,7 +4285,7 @@ export class FallbackFunctionAttribute { return new OverrideSpecifier(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4290,10 +4300,10 @@ export class FallbackFunctionAttribute { export class ReceiveFunctionAttribute { private readonly fetch: () => ModifierInvocation | OverrideSpecifier | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4303,7 +4313,7 @@ export class ReceiveFunctionAttribute { return new OverrideSpecifier(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4318,10 +4328,10 @@ export class ReceiveFunctionAttribute { export class ModifierAttribute { private readonly fetch: () => OverrideSpecifier | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4329,7 +4339,7 @@ export class ModifierAttribute { return new OverrideSpecifier(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4345,7 +4355,7 @@ export class ModifierAttribute { export class TypeName { private readonly fetch: () => ArrayTypeName | FunctionType | MappingType | ElementaryType | IdentifierPath = once( () => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.ArrayTypeName: @@ -4360,7 +4370,7 @@ export class TypeName { return new IdentifierPath(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }, ); @@ -4376,7 +4386,7 @@ export class TypeName { export class FunctionTypeAttribute { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4392,7 +4402,7 @@ export class FunctionTypeAttribute { export class MappingKeyType { private readonly fetch: () => ElementaryType | IdentifierPath = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.ElementaryType: @@ -4401,7 +4411,7 @@ export class MappingKeyType { return new IdentifierPath(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4416,10 +4426,10 @@ export class MappingKeyType { export class ElementaryType { private readonly fetch: () => AddressType | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4427,7 +4437,7 @@ export class ElementaryType { return new AddressType(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4459,7 +4469,7 @@ export class Statement { | TupleDeconstructionStatement | VariableDeclarationStatement | ExpressionStatement = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.IfStatement: @@ -4498,7 +4508,7 @@ export class Statement { return new ExpressionStatement(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4530,7 +4540,7 @@ export class Statement { export class TupleMember { private readonly fetch: () => TypedTupleMember | UntypedTupleMember = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.TypedTupleMember: @@ -4539,7 +4549,7 @@ export class TupleMember { return new UntypedTupleMember(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4554,10 +4564,10 @@ export class TupleMember { export class VariableDeclarationType { private readonly fetch: () => TypeName | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4565,7 +4575,7 @@ export class VariableDeclarationType { return new TypeName(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4580,7 +4590,7 @@ export class VariableDeclarationType { export class StorageLocation { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4600,10 +4610,10 @@ export class ForStatementInitialization { | VariableDeclarationStatement | ExpressionStatement | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4615,7 +4625,7 @@ export class ForStatementInitialization { return new ExpressionStatement(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4634,10 +4644,10 @@ export class ForStatementInitialization { export class ForStatementCondition { private readonly fetch: () => ExpressionStatement | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4645,7 +4655,7 @@ export class ForStatementCondition { return new ExpressionStatement(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4688,10 +4698,10 @@ export class Expression { | StringExpression | ElementaryType | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -4751,7 +4761,7 @@ export class Expression { return new ElementaryType(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4794,7 +4804,7 @@ export class Expression { export class ArgumentsDeclaration { private readonly fetch: () => PositionalArgumentsDeclaration | NamedArgumentsDeclaration = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.PositionalArgumentsDeclaration: @@ -4803,7 +4813,7 @@ export class ArgumentsDeclaration { return new NamedArgumentsDeclaration(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4818,7 +4828,7 @@ export class ArgumentsDeclaration { export class NumberUnit { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4839,7 +4849,7 @@ export class StringExpression { | HexStringLiteral | HexStringLiterals | UnicodeStringLiterals = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.StringLiteral: @@ -4854,7 +4864,7 @@ export class StringExpression { return new UnicodeStringLiterals(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4869,7 +4879,7 @@ export class StringExpression { export class StringLiteral { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4885,7 +4895,7 @@ export class StringLiteral { export class HexStringLiteral { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4901,7 +4911,7 @@ export class HexStringLiteral { export class UnicodeStringLiteral { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -4930,7 +4940,7 @@ export class YulStatement { | YulVariableDeclarationStatement | YulVariableAssignmentStatement | YulExpression = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.YulBlock: @@ -4961,7 +4971,7 @@ export class YulStatement { return new YulExpression(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -4989,10 +4999,10 @@ export class YulStatement { export class YulAssignmentOperator { private readonly fetch: () => YulColonAndEqual | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -5000,7 +5010,7 @@ export class YulAssignmentOperator { return new YulColonAndEqual(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -5015,10 +5025,10 @@ export class YulAssignmentOperator { export class YulStackAssignmentOperator { private readonly fetch: () => YulEqualAndColon | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -5026,7 +5036,7 @@ export class YulStackAssignmentOperator { return new YulEqualAndColon(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -5041,7 +5051,7 @@ export class YulStackAssignmentOperator { export class YulSwitchCase { private readonly fetch: () => YulDefaultCase | YulValueCase = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.YulDefaultCase: @@ -5050,7 +5060,7 @@ export class YulSwitchCase { return new YulValueCase(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -5065,7 +5075,7 @@ export class YulSwitchCase { export class YulExpression { private readonly fetch: () => YulFunctionCallExpression | YulLiteral | YulBuiltInFunction | YulPath = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.YulFunctionCallExpression: @@ -5078,7 +5088,7 @@ export class YulExpression { return new YulPath(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -5093,7 +5103,7 @@ export class YulExpression { export class YulPathComponent { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -5109,7 +5119,7 @@ export class YulPathComponent { export class YulBuiltInFunction { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -5125,10 +5135,10 @@ export class YulBuiltInFunction { export class YulLiteral { private readonly fetch: () => HexStringLiteral | StringLiteral | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -5138,7 +5148,7 @@ export class YulLiteral { return new StringLiteral(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -5157,7 +5167,7 @@ export class YulLiteral { export class SourceUnitMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new SourceUnitMember(item as NonterminalNode)); }); @@ -5172,7 +5182,7 @@ export class SourceUnitMembers { export class VersionExpressionSet { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new VersionExpression(item as NonterminalNode)); }); @@ -5187,7 +5197,7 @@ export class VersionExpressionSet { export class ContractMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ContractMember(item as NonterminalNode)); }); @@ -5202,7 +5212,7 @@ export class ContractMembers { export class InterfaceMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ContractMember(item as NonterminalNode)); }); @@ -5217,7 +5227,7 @@ export class InterfaceMembers { export class LibraryMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ContractMember(item as NonterminalNode)); }); @@ -5232,7 +5242,7 @@ export class LibraryMembers { export class StructMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new StructMember(item as NonterminalNode)); }); @@ -5247,7 +5257,7 @@ export class StructMembers { export class StateVariableAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new StateVariableAttribute(item as NonterminalNode)); }); @@ -5262,7 +5272,7 @@ export class StateVariableAttributes { export class FunctionAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new FunctionAttribute(item as NonterminalNode)); }); @@ -5277,7 +5287,7 @@ export class FunctionAttributes { export class ConstructorAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ConstructorAttribute(item as NonterminalNode)); }); @@ -5292,7 +5302,7 @@ export class ConstructorAttributes { export class UnnamedFunctionAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new UnnamedFunctionAttribute(item as NonterminalNode)); }); @@ -5307,7 +5317,7 @@ export class UnnamedFunctionAttributes { export class FallbackFunctionAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new FallbackFunctionAttribute(item as NonterminalNode)); }); @@ -5322,7 +5332,7 @@ export class FallbackFunctionAttributes { export class ReceiveFunctionAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ReceiveFunctionAttribute(item as NonterminalNode)); }); @@ -5337,7 +5347,7 @@ export class ReceiveFunctionAttributes { export class ModifierAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new ModifierAttribute(item as NonterminalNode)); }); @@ -5352,7 +5362,7 @@ export class ModifierAttributes { export class FunctionTypeAttributes { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new FunctionTypeAttribute(item as NonterminalNode)); }); @@ -5367,7 +5377,7 @@ export class FunctionTypeAttributes { export class Statements { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new Statement(item as NonterminalNode)); }); @@ -5382,7 +5392,7 @@ export class Statements { export class CatchClauses { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new CatchClause(item as NonterminalNode)); }); @@ -5397,7 +5407,7 @@ export class CatchClauses { export class StringLiterals { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new StringLiteral(item as NonterminalNode)); }); @@ -5412,7 +5422,7 @@ export class StringLiterals { export class HexStringLiterals { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new HexStringLiteral(item as NonterminalNode)); }); @@ -5427,7 +5437,7 @@ export class HexStringLiterals { export class UnicodeStringLiterals { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new UnicodeStringLiteral(item as NonterminalNode)); }); @@ -5442,7 +5452,7 @@ export class UnicodeStringLiterals { export class YulStatements { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new YulStatement(item as NonterminalNode)); }); @@ -5457,7 +5467,7 @@ export class YulStatements { export class YulSwitchCases { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new YulSwitchCase(item as NonterminalNode)); }); @@ -5476,10 +5486,10 @@ export class YulSwitchCases { export class VersionExpressionSets { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new VersionExpressionSet(item as NonterminalNode)), + items: items!.map((item) => new VersionExpressionSet(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5499,7 +5509,7 @@ export class VersionExpressionSets { export class SimpleVersionLiteral { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -5519,10 +5529,10 @@ export class SimpleVersionLiteral { export class ImportDeconstructionSymbols { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new ImportDeconstructionSymbol(item as NonterminalNode)), + items: items!.map((item) => new ImportDeconstructionSymbol(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5542,10 +5552,10 @@ export class ImportDeconstructionSymbols { export class UsingDeconstructionSymbols { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new UsingDeconstructionSymbol(item as NonterminalNode)), + items: items!.map((item) => new UsingDeconstructionSymbol(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5565,10 +5575,10 @@ export class UsingDeconstructionSymbols { export class InheritanceTypes { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new InheritanceType(item as NonterminalNode)), + items: items!.map((item) => new InheritanceType(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5588,7 +5598,7 @@ export class InheritanceTypes { export class EnumMembers { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -5608,10 +5618,10 @@ export class EnumMembers { export class Parameters { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new Parameter(item as NonterminalNode)), + items: items!.map((item) => new Parameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5631,10 +5641,10 @@ export class Parameters { export class OverridePaths { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new IdentifierPath(item as NonterminalNode)), + items: items!.map((item) => new IdentifierPath(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5654,10 +5664,10 @@ export class OverridePaths { export class EventParameters { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new EventParameter(item as NonterminalNode)), + items: items!.map((item) => new EventParameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5677,10 +5687,10 @@ export class EventParameters { export class ErrorParameters { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new ErrorParameter(item as NonterminalNode)), + items: items!.map((item) => new ErrorParameter(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5700,10 +5710,10 @@ export class ErrorParameters { export class AssemblyFlags { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new StringLiteral(item as NonterminalNode)), + items: items!.map((item) => new StringLiteral(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5723,10 +5733,10 @@ export class AssemblyFlags { export class TupleDeconstructionElements { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new TupleDeconstructionElement(item as NonterminalNode)), + items: items!.map((item) => new TupleDeconstructionElement(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5746,10 +5756,10 @@ export class TupleDeconstructionElements { export class PositionalArguments { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new Expression(item as NonterminalNode)), + items: items!.map((item) => new Expression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5769,10 +5779,10 @@ export class PositionalArguments { export class NamedArguments { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new NamedArgument(item as NonterminalNode)), + items: items!.map((item) => new NamedArgument(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5792,10 +5802,10 @@ export class NamedArguments { export class CallOptions { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new NamedArgument(item as NonterminalNode)), + items: items!.map((item) => new NamedArgument(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5815,10 +5825,10 @@ export class CallOptions { export class TupleValues { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new TupleValue(item as NonterminalNode)), + items: items!.map((item) => new TupleValue(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5838,10 +5848,10 @@ export class TupleValues { export class ArrayValues { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new Expression(item as NonterminalNode)), + items: items!.map((item) => new Expression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5861,7 +5871,7 @@ export class ArrayValues { export class IdentifierPath { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -5881,7 +5891,7 @@ export class IdentifierPath { export class YulParameters { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -5901,7 +5911,7 @@ export class YulParameters { export class YulVariableNames { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -5921,10 +5931,10 @@ export class YulVariableNames { export class YulArguments { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new YulExpression(item as NonterminalNode)), + items: items!.map((item) => new YulExpression(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5944,10 +5954,10 @@ export class YulArguments { export class YulPaths { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new YulPath(item as NonterminalNode)), + items: items!.map((item) => new YulPath(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -5967,10 +5977,10 @@ export class YulPaths { export class YulPath { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { - items: items.map((item) => new YulPathComponent(item as NonterminalNode)), + items: items!.map((item) => new YulPathComponent(item as NonterminalNode)), separators: separators as TerminalNode[], }; }); @@ -6003,5 +6013,9 @@ function once(factory: () => T): () => T { } function assertKind(actual: NonterminalKind, expected: NonterminalKind): void { - assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); + if (actual !== expected) { + throw new Error( + `AST node '${expected}' can only be initialized with a CST node of the same kind. Received '${actual}' instead.`, + ); + } } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs b/crates/solidity/outputs/npm/package/src/generated/ast/index.mts similarity index 70% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs rename to crates/solidity/outputs/npm/package/src/generated/ast/index.mts index 60ba962444..f4e4da9201 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cli/commands/mod.rs +++ b/crates/solidity/outputs/npm/package/src/generated/ast/index.mts @@ -1,3 +1,3 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -pub mod parse; +export * from "./generated/nodes.mjs"; diff --git a/crates/solidity/outputs/npm/package/src/generated/cst/index.mts b/crates/solidity/outputs/npm/package/src/generated/cst/index.mts new file mode 100644 index 0000000000..3bab65460e --- /dev/null +++ b/crates/solidity/outputs/npm/package/src/generated/cst/index.mts @@ -0,0 +1,81 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +import * as generated from "../../../wasm/index.mjs"; + +export const NonterminalKind = generated.cst.NonterminalKind; +export type NonterminalKind = generated.cst.NonterminalKind; + +export const TerminalKind = generated.cst.TerminalKind; +export type TerminalKind = generated.cst.TerminalKind; + +export const TerminalKindExtensions = generated.cst.TerminalKindExtensions; +export type TerminalKindExtensions = generated.cst.TerminalKindExtensions; + +export const EdgeLabel = generated.cst.EdgeLabel; +export type EdgeLabel = generated.cst.EdgeLabel; + +export type Node = generated.cst.Node; + +export const NodeVariant = generated.cst.NodeVariant; +export type NodeVariant = generated.cst.NodeVariant; + +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; + +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; + +export type Edge = generated.cst.Edge; + +export const Cursor = generated.cst.Cursor; +export type Cursor = generated.cst.Cursor; + +export const Query = generated.cst.Query; +export type Query = generated.cst.Query; + +export type QueryError = generated.cst.QueryError; + +export type QueryMatch = generated.cst.QueryMatch; + +export const QueryMatchIterator = generated.cst.QueryMatchIterator; +export type QueryMatchIterator = generated.cst.QueryMatchIterator; + +export type TextIndex = generated.cst.TextIndex; + +export type TextRange = generated.cst.TextRange; + +/* + * Helpers: + */ + +export function assertIsNonterminalNode( + node: unknown, + kind?: NonterminalKind, + text?: string, +): asserts node is NonterminalNode { + if (!(node instanceof NonterminalNode)) { + throw new Error("Node provided is not a NonterminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's NonterminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} + +export function assertIsTerminalNode(node: unknown, kind?: TerminalKind, text?: string): asserts node is TerminalNode { + if (!(node instanceof TerminalNode)) { + throw new Error("Node provided is not a TerminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's TerminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} diff --git a/crates/solidity/outputs/npm/package/src/generated/cst/index.ts b/crates/solidity/outputs/npm/package/src/generated/cst/index.ts deleted file mode 100644 index 7f845af258..0000000000 --- a/crates/solidity/outputs/npm/package/src/generated/cst/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -import * as generated from "../napi-bindings/generated"; - -export const NonterminalKind = generated.cst.NonterminalKind; -export type NonterminalKind = generated.cst.NonterminalKind; - -export const TerminalKind = generated.cst.TerminalKind; -export type TerminalKind = generated.cst.TerminalKind; - -export const EdgeLabel = generated.cst.EdgeLabel; -export type EdgeLabel = generated.cst.EdgeLabel; - -export type Node = generated.cst.Node; - -export const NodeType = generated.cst.NodeType; -export type NodeType = generated.cst.NodeType; - -export const NonterminalNode = generated.cst.NonterminalNode; -export type NonterminalNode = generated.cst.NonterminalNode; - -export const TerminalNode = generated.cst.TerminalNode; -export type TerminalNode = generated.cst.TerminalNode; - -export const Cursor = generated.cst.Cursor; -export type Cursor = generated.cst.Cursor; - -export const Query = generated.cst.Query; -export type Query = generated.cst.Query; - -export type QueryMatch = generated.cst.QueryMatch; - -export const QueryMatchIterator = generated.cst.QueryMatchIterator; -export type QueryMatchIterator = generated.cst.QueryMatchIterator; - -export type TextIndex = generated.cst.TextIndex; - -export type TextRange = generated.cst.TextRange; diff --git a/crates/solidity/outputs/npm/package/src/generated/diagnostic/index.ts b/crates/solidity/outputs/npm/package/src/generated/diagnostic/index.ts deleted file mode 100644 index 3de773e0d4..0000000000 --- a/crates/solidity/outputs/npm/package/src/generated/diagnostic/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -import * as generated from "../napi-bindings/generated"; - -export const Severity = generated.diagnostic.Severity; -export type Severity = generated.diagnostic.Severity; - -export const Diagnostic = generated.diagnostic.Diagnostic; -export type Diagnostic = generated.diagnostic.Diagnostic; - -// NOTE(#987): napi-rs does not allow us to either export traits as interfaces -// or interfaces with methods in general, so we define the interface ourselves. -export interface DiagnosticInterface { - textRange(): generated.cst.TextRange; - message(): string; - severity(): Severity; -} - -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; diff --git a/crates/solidity/outputs/npm/package/src/generated/index.mts b/crates/solidity/outputs/npm/package/src/generated/index.mts new file mode 100644 index 0000000000..847cd1d82b --- /dev/null +++ b/crates/solidity/outputs/npm/package/src/generated/index.mts @@ -0,0 +1,5 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export * as ast from "./ast/index.mjs"; +export * as cst from "./cst/index.mjs"; +export * as parser from "./parser/index.mjs"; diff --git a/crates/solidity/outputs/npm/package/src/generated/index.ts b/crates/solidity/outputs/npm/package/src/generated/index.ts deleted file mode 100644 index 7fb8ce0cac..0000000000 --- a/crates/solidity/outputs/npm/package/src/generated/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -export * as ast from "./ast"; -export * as cst from "./cst"; -export * as parser from "./parser"; diff --git a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts b/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts deleted file mode 100644 index a5ee013efb..0000000000 --- a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts +++ /dev/null @@ -1,864 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -export declare namespace cst { - export enum NonterminalKind { - ABICoderPragma = "ABICoderPragma", - AdditiveExpression = "AdditiveExpression", - AddressType = "AddressType", - AndExpression = "AndExpression", - ArgumentsDeclaration = "ArgumentsDeclaration", - ArrayExpression = "ArrayExpression", - ArrayTypeName = "ArrayTypeName", - ArrayValues = "ArrayValues", - AssemblyFlags = "AssemblyFlags", - AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", - AssemblyStatement = "AssemblyStatement", - AssignmentExpression = "AssignmentExpression", - BitwiseAndExpression = "BitwiseAndExpression", - BitwiseOrExpression = "BitwiseOrExpression", - BitwiseXorExpression = "BitwiseXorExpression", - Block = "Block", - BreakStatement = "BreakStatement", - CallOptions = "CallOptions", - CallOptionsExpression = "CallOptionsExpression", - CatchClause = "CatchClause", - CatchClauseError = "CatchClauseError", - CatchClauses = "CatchClauses", - ComparisonExpression = "ComparisonExpression", - ConditionalExpression = "ConditionalExpression", - ConstantDefinition = "ConstantDefinition", - ConstructorAttribute = "ConstructorAttribute", - ConstructorAttributes = "ConstructorAttributes", - ConstructorDefinition = "ConstructorDefinition", - ContinueStatement = "ContinueStatement", - ContractDefinition = "ContractDefinition", - ContractMember = "ContractMember", - ContractMembers = "ContractMembers", - DecimalNumberExpression = "DecimalNumberExpression", - DoWhileStatement = "DoWhileStatement", - ElementaryType = "ElementaryType", - ElseBranch = "ElseBranch", - EmitStatement = "EmitStatement", - EnumDefinition = "EnumDefinition", - EnumMembers = "EnumMembers", - EqualityExpression = "EqualityExpression", - ErrorDefinition = "ErrorDefinition", - ErrorParameter = "ErrorParameter", - ErrorParameters = "ErrorParameters", - ErrorParametersDeclaration = "ErrorParametersDeclaration", - EventDefinition = "EventDefinition", - EventParameter = "EventParameter", - EventParameters = "EventParameters", - EventParametersDeclaration = "EventParametersDeclaration", - ExperimentalFeature = "ExperimentalFeature", - ExperimentalPragma = "ExperimentalPragma", - ExponentiationExpression = "ExponentiationExpression", - Expression = "Expression", - ExpressionStatement = "ExpressionStatement", - FallbackFunctionAttribute = "FallbackFunctionAttribute", - FallbackFunctionAttributes = "FallbackFunctionAttributes", - FallbackFunctionDefinition = "FallbackFunctionDefinition", - ForStatement = "ForStatement", - ForStatementCondition = "ForStatementCondition", - ForStatementInitialization = "ForStatementInitialization", - FunctionAttribute = "FunctionAttribute", - FunctionAttributes = "FunctionAttributes", - FunctionBody = "FunctionBody", - FunctionCallExpression = "FunctionCallExpression", - FunctionDefinition = "FunctionDefinition", - FunctionName = "FunctionName", - FunctionType = "FunctionType", - FunctionTypeAttribute = "FunctionTypeAttribute", - FunctionTypeAttributes = "FunctionTypeAttributes", - HexNumberExpression = "HexNumberExpression", - HexStringLiteral = "HexStringLiteral", - HexStringLiterals = "HexStringLiterals", - IdentifierPath = "IdentifierPath", - IfStatement = "IfStatement", - ImportAlias = "ImportAlias", - ImportClause = "ImportClause", - ImportDeconstruction = "ImportDeconstruction", - ImportDeconstructionSymbol = "ImportDeconstructionSymbol", - ImportDeconstructionSymbols = "ImportDeconstructionSymbols", - ImportDirective = "ImportDirective", - IndexAccessEnd = "IndexAccessEnd", - IndexAccessExpression = "IndexAccessExpression", - InheritanceSpecifier = "InheritanceSpecifier", - InheritanceType = "InheritanceType", - InheritanceTypes = "InheritanceTypes", - InterfaceDefinition = "InterfaceDefinition", - InterfaceMembers = "InterfaceMembers", - LibraryDefinition = "LibraryDefinition", - LibraryMembers = "LibraryMembers", - MappingKey = "MappingKey", - MappingKeyType = "MappingKeyType", - MappingType = "MappingType", - MappingValue = "MappingValue", - MemberAccessExpression = "MemberAccessExpression", - ModifierAttribute = "ModifierAttribute", - ModifierAttributes = "ModifierAttributes", - ModifierDefinition = "ModifierDefinition", - ModifierInvocation = "ModifierInvocation", - MultiplicativeExpression = "MultiplicativeExpression", - NamedArgument = "NamedArgument", - NamedArgumentGroup = "NamedArgumentGroup", - NamedArguments = "NamedArguments", - NamedArgumentsDeclaration = "NamedArgumentsDeclaration", - NamedImport = "NamedImport", - NewExpression = "NewExpression", - NumberUnit = "NumberUnit", - OrExpression = "OrExpression", - OverridePaths = "OverridePaths", - OverridePathsDeclaration = "OverridePathsDeclaration", - OverrideSpecifier = "OverrideSpecifier", - Parameter = "Parameter", - Parameters = "Parameters", - ParametersDeclaration = "ParametersDeclaration", - PathImport = "PathImport", - PositionalArguments = "PositionalArguments", - PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", - PostfixExpression = "PostfixExpression", - Pragma = "Pragma", - PragmaDirective = "PragmaDirective", - PrefixExpression = "PrefixExpression", - ReceiveFunctionAttribute = "ReceiveFunctionAttribute", - ReceiveFunctionAttributes = "ReceiveFunctionAttributes", - ReceiveFunctionDefinition = "ReceiveFunctionDefinition", - ReturnStatement = "ReturnStatement", - ReturnsDeclaration = "ReturnsDeclaration", - RevertStatement = "RevertStatement", - ShiftExpression = "ShiftExpression", - SimpleVersionLiteral = "SimpleVersionLiteral", - SourceUnit = "SourceUnit", - SourceUnitMember = "SourceUnitMember", - SourceUnitMembers = "SourceUnitMembers", - StateVariableAttribute = "StateVariableAttribute", - StateVariableAttributes = "StateVariableAttributes", - StateVariableDefinition = "StateVariableDefinition", - StateVariableDefinitionValue = "StateVariableDefinitionValue", - Statement = "Statement", - Statements = "Statements", - StorageLocation = "StorageLocation", - StringExpression = "StringExpression", - StringLiteral = "StringLiteral", - StringLiterals = "StringLiterals", - StructDefinition = "StructDefinition", - StructMember = "StructMember", - StructMembers = "StructMembers", - ThrowStatement = "ThrowStatement", - TryStatement = "TryStatement", - TupleDeconstructionElement = "TupleDeconstructionElement", - TupleDeconstructionElements = "TupleDeconstructionElements", - TupleDeconstructionStatement = "TupleDeconstructionStatement", - TupleExpression = "TupleExpression", - TupleMember = "TupleMember", - TupleValue = "TupleValue", - TupleValues = "TupleValues", - TypeExpression = "TypeExpression", - TypeName = "TypeName", - TypedTupleMember = "TypedTupleMember", - UncheckedBlock = "UncheckedBlock", - UnicodeStringLiteral = "UnicodeStringLiteral", - UnicodeStringLiterals = "UnicodeStringLiterals", - UnnamedFunctionAttribute = "UnnamedFunctionAttribute", - UnnamedFunctionAttributes = "UnnamedFunctionAttributes", - UnnamedFunctionDefinition = "UnnamedFunctionDefinition", - UntypedTupleMember = "UntypedTupleMember", - UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", - UsingAlias = "UsingAlias", - UsingClause = "UsingClause", - UsingDeconstruction = "UsingDeconstruction", - UsingDeconstructionSymbol = "UsingDeconstructionSymbol", - UsingDeconstructionSymbols = "UsingDeconstructionSymbols", - UsingDirective = "UsingDirective", - UsingOperator = "UsingOperator", - UsingTarget = "UsingTarget", - VariableDeclarationStatement = "VariableDeclarationStatement", - VariableDeclarationType = "VariableDeclarationType", - VariableDeclarationValue = "VariableDeclarationValue", - VersionExpression = "VersionExpression", - VersionExpressionSet = "VersionExpressionSet", - VersionExpressionSets = "VersionExpressionSets", - VersionLiteral = "VersionLiteral", - VersionOperator = "VersionOperator", - VersionPragma = "VersionPragma", - VersionRange = "VersionRange", - VersionTerm = "VersionTerm", - WhileStatement = "WhileStatement", - YulArguments = "YulArguments", - YulAssignmentOperator = "YulAssignmentOperator", - YulBlock = "YulBlock", - YulBreakStatement = "YulBreakStatement", - YulBuiltInFunction = "YulBuiltInFunction", - YulColonAndEqual = "YulColonAndEqual", - YulContinueStatement = "YulContinueStatement", - YulDefaultCase = "YulDefaultCase", - YulEqualAndColon = "YulEqualAndColon", - YulExpression = "YulExpression", - YulForStatement = "YulForStatement", - YulFunctionCallExpression = "YulFunctionCallExpression", - YulFunctionDefinition = "YulFunctionDefinition", - YulIfStatement = "YulIfStatement", - YulLabel = "YulLabel", - YulLeaveStatement = "YulLeaveStatement", - YulLiteral = "YulLiteral", - YulParameters = "YulParameters", - YulParametersDeclaration = "YulParametersDeclaration", - YulPath = "YulPath", - YulPathComponent = "YulPathComponent", - YulPaths = "YulPaths", - YulReturnsDeclaration = "YulReturnsDeclaration", - YulStackAssignmentOperator = "YulStackAssignmentOperator", - YulStackAssignmentStatement = "YulStackAssignmentStatement", - YulStatement = "YulStatement", - YulStatements = "YulStatements", - YulSwitchCase = "YulSwitchCase", - YulSwitchCases = "YulSwitchCases", - YulSwitchStatement = "YulSwitchStatement", - YulValueCase = "YulValueCase", - YulVariableAssignmentStatement = "YulVariableAssignmentStatement", - YulVariableDeclarationStatement = "YulVariableDeclarationStatement", - YulVariableDeclarationValue = "YulVariableDeclarationValue", - YulVariableNames = "YulVariableNames", - } - export enum EdgeLabel { - Item = "Item", - Variant = "Variant", - Separator = "Separator", - Operand = "Operand", - LeftOperand = "LeftOperand", - RightOperand = "RightOperand", - LeadingTrivia = "LeadingTrivia", - TrailingTrivia = "TrailingTrivia", - AbicoderKeyword = "AbicoderKeyword", - AbstractKeyword = "AbstractKeyword", - AddressKeyword = "AddressKeyword", - Alias = "Alias", - AnonymousKeyword = "AnonymousKeyword", - Arguments = "Arguments", - AsKeyword = "AsKeyword", - AssemblyKeyword = "AssemblyKeyword", - Assignment = "Assignment", - Asterisk = "Asterisk", - Attributes = "Attributes", - Block = "Block", - Body = "Body", - BreakKeyword = "BreakKeyword", - CaseKeyword = "CaseKeyword", - Cases = "Cases", - CatchClauses = "CatchClauses", - CatchKeyword = "CatchKeyword", - Clause = "Clause", - CloseBrace = "CloseBrace", - CloseBracket = "CloseBracket", - CloseParen = "CloseParen", - Colon = "Colon", - Condition = "Condition", - ConstantKeyword = "ConstantKeyword", - ConstructorKeyword = "ConstructorKeyword", - ContinueKeyword = "ContinueKeyword", - ContractKeyword = "ContractKeyword", - DefaultKeyword = "DefaultKeyword", - DoKeyword = "DoKeyword", - Elements = "Elements", - ElseBranch = "ElseBranch", - ElseKeyword = "ElseKeyword", - EmitKeyword = "EmitKeyword", - End = "End", - EnumKeyword = "EnumKeyword", - Equal = "Equal", - EqualGreaterThan = "EqualGreaterThan", - Error = "Error", - ErrorKeyword = "ErrorKeyword", - Event = "Event", - EventKeyword = "EventKeyword", - ExperimentalKeyword = "ExperimentalKeyword", - Expression = "Expression", - FallbackKeyword = "FallbackKeyword", - FalseExpression = "FalseExpression", - Feature = "Feature", - Flags = "Flags", - ForKeyword = "ForKeyword", - FromKeyword = "FromKeyword", - FunctionKeyword = "FunctionKeyword", - GlobalKeyword = "GlobalKeyword", - Identifier = "Identifier", - IfKeyword = "IfKeyword", - ImportKeyword = "ImportKeyword", - Index = "Index", - IndexedKeyword = "IndexedKeyword", - Inheritance = "Inheritance", - Initialization = "Initialization", - InterfaceKeyword = "InterfaceKeyword", - IsKeyword = "IsKeyword", - Items = "Items", - Iterator = "Iterator", - KeyType = "KeyType", - Label = "Label", - LeaveKeyword = "LeaveKeyword", - LetKeyword = "LetKeyword", - LibraryKeyword = "LibraryKeyword", - Literal = "Literal", - MappingKeyword = "MappingKeyword", - Member = "Member", - Members = "Members", - Minus = "Minus", - MinusGreaterThan = "MinusGreaterThan", - ModifierKeyword = "ModifierKeyword", - Name = "Name", - NewKeyword = "NewKeyword", - OpenBrace = "OpenBrace", - OpenBracket = "OpenBracket", - OpenParen = "OpenParen", - Operator = "Operator", - Options = "Options", - Overridden = "Overridden", - OverrideKeyword = "OverrideKeyword", - Parameters = "Parameters", - Path = "Path", - Paths = "Paths", - PayableKeyword = "PayableKeyword", - Period = "Period", - Pragma = "Pragma", - PragmaKeyword = "PragmaKeyword", - QuestionMark = "QuestionMark", - ReceiveKeyword = "ReceiveKeyword", - ReturnKeyword = "ReturnKeyword", - Returns = "Returns", - ReturnsKeyword = "ReturnsKeyword", - RevertKeyword = "RevertKeyword", - Semicolon = "Semicolon", - Sets = "Sets", - SolidityKeyword = "SolidityKeyword", - Start = "Start", - Statements = "Statements", - StorageLocation = "StorageLocation", - StructKeyword = "StructKeyword", - SwitchKeyword = "SwitchKeyword", - Symbols = "Symbols", - Target = "Target", - ThrowKeyword = "ThrowKeyword", - TrueExpression = "TrueExpression", - TryKeyword = "TryKeyword", - TypeKeyword = "TypeKeyword", - TypeName = "TypeName", - Types = "Types", - UncheckedKeyword = "UncheckedKeyword", - Unit = "Unit", - UsingKeyword = "UsingKeyword", - Value = "Value", - ValueType = "ValueType", - VarKeyword = "VarKeyword", - Variable = "Variable", - VariableType = "VariableType", - Variables = "Variables", - Version = "Version", - WhileKeyword = "WhileKeyword", - } - export enum TerminalKind { - UNRECOGNIZED = "UNRECOGNIZED", - MISSING = "MISSING", - AbicoderKeyword = "AbicoderKeyword", - AbstractKeyword = "AbstractKeyword", - AddressKeyword = "AddressKeyword", - AfterKeyword = "AfterKeyword", - AliasKeyword = "AliasKeyword", - Ampersand = "Ampersand", - AmpersandAmpersand = "AmpersandAmpersand", - AmpersandEqual = "AmpersandEqual", - AnonymousKeyword = "AnonymousKeyword", - ApplyKeyword = "ApplyKeyword", - AsKeyword = "AsKeyword", - AssemblyKeyword = "AssemblyKeyword", - Asterisk = "Asterisk", - AsteriskAsterisk = "AsteriskAsterisk", - AsteriskEqual = "AsteriskEqual", - AutoKeyword = "AutoKeyword", - Bang = "Bang", - BangEqual = "BangEqual", - Bar = "Bar", - BarBar = "BarBar", - BarEqual = "BarEqual", - BoolKeyword = "BoolKeyword", - BreakKeyword = "BreakKeyword", - ByteKeyword = "ByteKeyword", - BytesKeyword = "BytesKeyword", - CallDataKeyword = "CallDataKeyword", - Caret = "Caret", - CaretEqual = "CaretEqual", - CaseKeyword = "CaseKeyword", - CatchKeyword = "CatchKeyword", - CloseBrace = "CloseBrace", - CloseBracket = "CloseBracket", - CloseParen = "CloseParen", - Colon = "Colon", - ColonEqual = "ColonEqual", - Comma = "Comma", - ConstantKeyword = "ConstantKeyword", - ConstructorKeyword = "ConstructorKeyword", - ContinueKeyword = "ContinueKeyword", - ContractKeyword = "ContractKeyword", - CopyOfKeyword = "CopyOfKeyword", - DaysKeyword = "DaysKeyword", - DecimalLiteral = "DecimalLiteral", - DefaultKeyword = "DefaultKeyword", - DefineKeyword = "DefineKeyword", - DeleteKeyword = "DeleteKeyword", - DoKeyword = "DoKeyword", - DoubleQuotedHexStringLiteral = "DoubleQuotedHexStringLiteral", - DoubleQuotedStringLiteral = "DoubleQuotedStringLiteral", - DoubleQuotedUnicodeStringLiteral = "DoubleQuotedUnicodeStringLiteral", - DoubleQuotedVersionLiteral = "DoubleQuotedVersionLiteral", - ElseKeyword = "ElseKeyword", - EmitKeyword = "EmitKeyword", - EndOfLine = "EndOfLine", - EnumKeyword = "EnumKeyword", - Equal = "Equal", - EqualColon = "EqualColon", - EqualEqual = "EqualEqual", - EqualGreaterThan = "EqualGreaterThan", - ErrorKeyword = "ErrorKeyword", - EtherKeyword = "EtherKeyword", - EventKeyword = "EventKeyword", - ExperimentalKeyword = "ExperimentalKeyword", - ExternalKeyword = "ExternalKeyword", - FallbackKeyword = "FallbackKeyword", - FalseKeyword = "FalseKeyword", - FinalKeyword = "FinalKeyword", - FinneyKeyword = "FinneyKeyword", - FixedKeyword = "FixedKeyword", - ForKeyword = "ForKeyword", - FromKeyword = "FromKeyword", - FunctionKeyword = "FunctionKeyword", - GlobalKeyword = "GlobalKeyword", - GreaterThan = "GreaterThan", - GreaterThanEqual = "GreaterThanEqual", - GreaterThanGreaterThan = "GreaterThanGreaterThan", - GreaterThanGreaterThanEqual = "GreaterThanGreaterThanEqual", - GreaterThanGreaterThanGreaterThan = "GreaterThanGreaterThanGreaterThan", - GreaterThanGreaterThanGreaterThanEqual = "GreaterThanGreaterThanGreaterThanEqual", - GweiKeyword = "GweiKeyword", - HexKeyword = "HexKeyword", - HexLiteral = "HexLiteral", - HoursKeyword = "HoursKeyword", - Identifier = "Identifier", - IfKeyword = "IfKeyword", - ImmutableKeyword = "ImmutableKeyword", - ImplementsKeyword = "ImplementsKeyword", - ImportKeyword = "ImportKeyword", - InKeyword = "InKeyword", - IndexedKeyword = "IndexedKeyword", - InlineKeyword = "InlineKeyword", - IntKeyword = "IntKeyword", - InterfaceKeyword = "InterfaceKeyword", - InternalKeyword = "InternalKeyword", - IsKeyword = "IsKeyword", - LessThan = "LessThan", - LessThanEqual = "LessThanEqual", - LessThanLessThan = "LessThanLessThan", - LessThanLessThanEqual = "LessThanLessThanEqual", - LetKeyword = "LetKeyword", - LibraryKeyword = "LibraryKeyword", - MacroKeyword = "MacroKeyword", - MappingKeyword = "MappingKeyword", - MatchKeyword = "MatchKeyword", - MemoryKeyword = "MemoryKeyword", - Minus = "Minus", - MinusEqual = "MinusEqual", - MinusGreaterThan = "MinusGreaterThan", - MinusMinus = "MinusMinus", - MinutesKeyword = "MinutesKeyword", - ModifierKeyword = "ModifierKeyword", - MultiLineComment = "MultiLineComment", - MultiLineNatSpecComment = "MultiLineNatSpecComment", - MutableKeyword = "MutableKeyword", - NewKeyword = "NewKeyword", - NullKeyword = "NullKeyword", - OfKeyword = "OfKeyword", - OpenBrace = "OpenBrace", - OpenBracket = "OpenBracket", - OpenParen = "OpenParen", - OverrideKeyword = "OverrideKeyword", - PartialKeyword = "PartialKeyword", - PayableKeyword = "PayableKeyword", - Percent = "Percent", - PercentEqual = "PercentEqual", - Period = "Period", - Plus = "Plus", - PlusEqual = "PlusEqual", - PlusPlus = "PlusPlus", - PragmaKeyword = "PragmaKeyword", - PrivateKeyword = "PrivateKeyword", - PromiseKeyword = "PromiseKeyword", - PublicKeyword = "PublicKeyword", - PureKeyword = "PureKeyword", - QuestionMark = "QuestionMark", - ReceiveKeyword = "ReceiveKeyword", - ReferenceKeyword = "ReferenceKeyword", - RelocatableKeyword = "RelocatableKeyword", - ReturnKeyword = "ReturnKeyword", - ReturnsKeyword = "ReturnsKeyword", - RevertKeyword = "RevertKeyword", - SealedKeyword = "SealedKeyword", - SecondsKeyword = "SecondsKeyword", - Semicolon = "Semicolon", - SingleLineComment = "SingleLineComment", - SingleLineNatSpecComment = "SingleLineNatSpecComment", - SingleQuotedHexStringLiteral = "SingleQuotedHexStringLiteral", - SingleQuotedStringLiteral = "SingleQuotedStringLiteral", - SingleQuotedUnicodeStringLiteral = "SingleQuotedUnicodeStringLiteral", - SingleQuotedVersionLiteral = "SingleQuotedVersionLiteral", - SizeOfKeyword = "SizeOfKeyword", - Slash = "Slash", - SlashEqual = "SlashEqual", - SolidityKeyword = "SolidityKeyword", - StaticKeyword = "StaticKeyword", - StorageKeyword = "StorageKeyword", - StringKeyword = "StringKeyword", - StructKeyword = "StructKeyword", - SupportsKeyword = "SupportsKeyword", - SwitchKeyword = "SwitchKeyword", - SzaboKeyword = "SzaboKeyword", - ThrowKeyword = "ThrowKeyword", - Tilde = "Tilde", - TransientKeyword = "TransientKeyword", - TrueKeyword = "TrueKeyword", - TryKeyword = "TryKeyword", - TypeDefKeyword = "TypeDefKeyword", - TypeKeyword = "TypeKeyword", - TypeOfKeyword = "TypeOfKeyword", - UfixedKeyword = "UfixedKeyword", - UintKeyword = "UintKeyword", - UncheckedKeyword = "UncheckedKeyword", - UsingKeyword = "UsingKeyword", - VarKeyword = "VarKeyword", - VersionSpecifier = "VersionSpecifier", - ViewKeyword = "ViewKeyword", - VirtualKeyword = "VirtualKeyword", - WeeksKeyword = "WeeksKeyword", - WeiKeyword = "WeiKeyword", - WhileKeyword = "WhileKeyword", - Whitespace = "Whitespace", - YearsKeyword = "YearsKeyword", - YulAbstractKeyword = "YulAbstractKeyword", - YulAddKeyword = "YulAddKeyword", - YulAddModKeyword = "YulAddModKeyword", - YulAddressKeyword = "YulAddressKeyword", - YulAfterKeyword = "YulAfterKeyword", - YulAliasKeyword = "YulAliasKeyword", - YulAndKeyword = "YulAndKeyword", - YulAnonymousKeyword = "YulAnonymousKeyword", - YulApplyKeyword = "YulApplyKeyword", - YulAsKeyword = "YulAsKeyword", - YulAssemblyKeyword = "YulAssemblyKeyword", - YulAutoKeyword = "YulAutoKeyword", - YulBalanceKeyword = "YulBalanceKeyword", - YulBaseFeeKeyword = "YulBaseFeeKeyword", - YulBlobBaseFeeKeyword = "YulBlobBaseFeeKeyword", - YulBlobHashKeyword = "YulBlobHashKeyword", - YulBlockHashKeyword = "YulBlockHashKeyword", - YulBoolKeyword = "YulBoolKeyword", - YulBreakKeyword = "YulBreakKeyword", - YulByteKeyword = "YulByteKeyword", - YulBytesKeyword = "YulBytesKeyword", - YulCallCodeKeyword = "YulCallCodeKeyword", - YulCallDataCopyKeyword = "YulCallDataCopyKeyword", - YulCallDataKeyword = "YulCallDataKeyword", - YulCallDataLoadKeyword = "YulCallDataLoadKeyword", - YulCallDataSizeKeyword = "YulCallDataSizeKeyword", - YulCallKeyword = "YulCallKeyword", - YulCallValueKeyword = "YulCallValueKeyword", - YulCallerKeyword = "YulCallerKeyword", - YulCaseKeyword = "YulCaseKeyword", - YulCatchKeyword = "YulCatchKeyword", - YulChainIdKeyword = "YulChainIdKeyword", - YulCoinBaseKeyword = "YulCoinBaseKeyword", - YulConstantKeyword = "YulConstantKeyword", - YulConstructorKeyword = "YulConstructorKeyword", - YulContinueKeyword = "YulContinueKeyword", - YulContractKeyword = "YulContractKeyword", - YulCopyOfKeyword = "YulCopyOfKeyword", - YulCreate2Keyword = "YulCreate2Keyword", - YulCreateKeyword = "YulCreateKeyword", - YulDaysKeyword = "YulDaysKeyword", - YulDecimalLiteral = "YulDecimalLiteral", - YulDefaultKeyword = "YulDefaultKeyword", - YulDefineKeyword = "YulDefineKeyword", - YulDelegateCallKeyword = "YulDelegateCallKeyword", - YulDeleteKeyword = "YulDeleteKeyword", - YulDifficultyKeyword = "YulDifficultyKeyword", - YulDivKeyword = "YulDivKeyword", - YulDoKeyword = "YulDoKeyword", - YulElseKeyword = "YulElseKeyword", - YulEmitKeyword = "YulEmitKeyword", - YulEnumKeyword = "YulEnumKeyword", - YulEqKeyword = "YulEqKeyword", - YulEtherKeyword = "YulEtherKeyword", - YulEventKeyword = "YulEventKeyword", - YulExpKeyword = "YulExpKeyword", - YulExtCodeCopyKeyword = "YulExtCodeCopyKeyword", - YulExtCodeHashKeyword = "YulExtCodeHashKeyword", - YulExtCodeSizeKeyword = "YulExtCodeSizeKeyword", - YulExternalKeyword = "YulExternalKeyword", - YulFallbackKeyword = "YulFallbackKeyword", - YulFalseKeyword = "YulFalseKeyword", - YulFinalKeyword = "YulFinalKeyword", - YulFinneyKeyword = "YulFinneyKeyword", - YulFixedKeyword = "YulFixedKeyword", - YulForKeyword = "YulForKeyword", - YulFunctionKeyword = "YulFunctionKeyword", - YulGasKeyword = "YulGasKeyword", - YulGasLimitKeyword = "YulGasLimitKeyword", - YulGasPriceKeyword = "YulGasPriceKeyword", - YulGtKeyword = "YulGtKeyword", - YulGweiKeyword = "YulGweiKeyword", - YulHexKeyword = "YulHexKeyword", - YulHexLiteral = "YulHexLiteral", - YulHoursKeyword = "YulHoursKeyword", - YulIdentifier = "YulIdentifier", - YulIfKeyword = "YulIfKeyword", - YulImmutableKeyword = "YulImmutableKeyword", - YulImplementsKeyword = "YulImplementsKeyword", - YulImportKeyword = "YulImportKeyword", - YulInKeyword = "YulInKeyword", - YulIndexedKeyword = "YulIndexedKeyword", - YulInlineKeyword = "YulInlineKeyword", - YulIntKeyword = "YulIntKeyword", - YulInterfaceKeyword = "YulInterfaceKeyword", - YulInternalKeyword = "YulInternalKeyword", - YulInvalidKeyword = "YulInvalidKeyword", - YulIsKeyword = "YulIsKeyword", - YulIsZeroKeyword = "YulIsZeroKeyword", - YulKeccak256Keyword = "YulKeccak256Keyword", - YulLeaveKeyword = "YulLeaveKeyword", - YulLetKeyword = "YulLetKeyword", - YulLibraryKeyword = "YulLibraryKeyword", - YulLog0Keyword = "YulLog0Keyword", - YulLog1Keyword = "YulLog1Keyword", - YulLog2Keyword = "YulLog2Keyword", - YulLog3Keyword = "YulLog3Keyword", - YulLog4Keyword = "YulLog4Keyword", - YulLtKeyword = "YulLtKeyword", - YulMCopyKeyword = "YulMCopyKeyword", - YulMLoadKeyword = "YulMLoadKeyword", - YulMSizeKeyword = "YulMSizeKeyword", - YulMStore8Keyword = "YulMStore8Keyword", - YulMStoreKeyword = "YulMStoreKeyword", - YulMacroKeyword = "YulMacroKeyword", - YulMappingKeyword = "YulMappingKeyword", - YulMatchKeyword = "YulMatchKeyword", - YulMemoryKeyword = "YulMemoryKeyword", - YulMinutesKeyword = "YulMinutesKeyword", - YulModKeyword = "YulModKeyword", - YulModifierKeyword = "YulModifierKeyword", - YulMulKeyword = "YulMulKeyword", - YulMulModKeyword = "YulMulModKeyword", - YulMutableKeyword = "YulMutableKeyword", - YulNewKeyword = "YulNewKeyword", - YulNotKeyword = "YulNotKeyword", - YulNullKeyword = "YulNullKeyword", - YulNumberKeyword = "YulNumberKeyword", - YulOfKeyword = "YulOfKeyword", - YulOrKeyword = "YulOrKeyword", - YulOriginKeyword = "YulOriginKeyword", - YulOverrideKeyword = "YulOverrideKeyword", - YulPartialKeyword = "YulPartialKeyword", - YulPayableKeyword = "YulPayableKeyword", - YulPopKeyword = "YulPopKeyword", - YulPragmaKeyword = "YulPragmaKeyword", - YulPrevRandaoKeyword = "YulPrevRandaoKeyword", - YulPrivateKeyword = "YulPrivateKeyword", - YulPromiseKeyword = "YulPromiseKeyword", - YulPublicKeyword = "YulPublicKeyword", - YulPureKeyword = "YulPureKeyword", - YulReceiveKeyword = "YulReceiveKeyword", - YulReferenceKeyword = "YulReferenceKeyword", - YulRelocatableKeyword = "YulRelocatableKeyword", - YulReturnDataCopyKeyword = "YulReturnDataCopyKeyword", - YulReturnDataSizeKeyword = "YulReturnDataSizeKeyword", - YulReturnKeyword = "YulReturnKeyword", - YulReturnsKeyword = "YulReturnsKeyword", - YulRevertKeyword = "YulRevertKeyword", - YulSDivKeyword = "YulSDivKeyword", - YulSLoadKeyword = "YulSLoadKeyword", - YulSModKeyword = "YulSModKeyword", - YulSStoreKeyword = "YulSStoreKeyword", - YulSarKeyword = "YulSarKeyword", - YulSealedKeyword = "YulSealedKeyword", - YulSecondsKeyword = "YulSecondsKeyword", - YulSelfBalanceKeyword = "YulSelfBalanceKeyword", - YulSelfDestructKeyword = "YulSelfDestructKeyword", - YulSgtKeyword = "YulSgtKeyword", - YulSha3Keyword = "YulSha3Keyword", - YulShlKeyword = "YulShlKeyword", - YulShrKeyword = "YulShrKeyword", - YulSignExtendKeyword = "YulSignExtendKeyword", - YulSizeOfKeyword = "YulSizeOfKeyword", - YulSltKeyword = "YulSltKeyword", - YulStaticCallKeyword = "YulStaticCallKeyword", - YulStaticKeyword = "YulStaticKeyword", - YulStopKeyword = "YulStopKeyword", - YulStorageKeyword = "YulStorageKeyword", - YulStringKeyword = "YulStringKeyword", - YulStructKeyword = "YulStructKeyword", - YulSubKeyword = "YulSubKeyword", - YulSuicideKeyword = "YulSuicideKeyword", - YulSupportsKeyword = "YulSupportsKeyword", - YulSwitchKeyword = "YulSwitchKeyword", - YulSzaboKeyword = "YulSzaboKeyword", - YulTLoadKeyword = "YulTLoadKeyword", - YulTStoreKeyword = "YulTStoreKeyword", - YulThrowKeyword = "YulThrowKeyword", - YulTimestampKeyword = "YulTimestampKeyword", - YulTrueKeyword = "YulTrueKeyword", - YulTryKeyword = "YulTryKeyword", - YulTypeDefKeyword = "YulTypeDefKeyword", - YulTypeKeyword = "YulTypeKeyword", - YulTypeOfKeyword = "YulTypeOfKeyword", - YulUfixedKeyword = "YulUfixedKeyword", - YulUintKeyword = "YulUintKeyword", - YulUncheckedKeyword = "YulUncheckedKeyword", - YulUsingKeyword = "YulUsingKeyword", - YulVarKeyword = "YulVarKeyword", - YulViewKeyword = "YulViewKeyword", - YulVirtualKeyword = "YulVirtualKeyword", - YulWeeksKeyword = "YulWeeksKeyword", - YulWeiKeyword = "YulWeiKeyword", - YulWhileKeyword = "YulWhileKeyword", - YulXorKeyword = "YulXorKeyword", - YulYearsKeyword = "YulYearsKeyword", - } - export enum NodeType { - Nonterminal = "Nonterminal", - Terminal = "Terminal", - } - export interface QueryMatch { - queryNumber: number; - captures: { [key: string]: cst.Cursor[] }; - } - export interface TextIndex { - utf8: number; - utf16: number; - line: number; - column: number; - } - export interface TextRange { - start: TextIndex; - end: TextIndex; - } - export class NonterminalNode { - get type(): cst.NodeType.Nonterminal; - get kind(): cst.NonterminalKind; - get textLength(): cst.TextIndex; - children(): Array; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - /** Serialize the node to JSON. */ - toJSON(): string; - unparse(): string; - } - export class TerminalNode { - get type(): cst.NodeType.Terminal; - get kind(): cst.TerminalKind; - get textLength(): cst.TextIndex; - get text(): string; - /** Serialize the node to JSON. */ - toJSON(): string; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - } - export class Cursor { - reset(): void; - complete(): void; - clone(): Cursor; - spawn(): Cursor; - get isCompleted(): boolean; - node(): cst.Node; - get label(): cst.EdgeLabel; - get textOffset(): cst.TextIndex; - get textRange(): cst.TextRange; - get depth(): number; - ancestors(): Array; - goToNext(): boolean; - goToNextNonDescendent(): boolean; - goToPrevious(): boolean; - goToParent(): boolean; - goToFirstChild(): boolean; - goToLastChild(): boolean; - goToNthChild(childNumber: number): boolean; - goToNextSibling(): boolean; - goToPreviousSibling(): boolean; - goToNextTerminal(): boolean; - goToNextTerminalWithKind(kind: cst.TerminalKind): boolean; - goToNextTerminalWithKinds(kinds: Array): boolean; - goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: cst.NonterminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; - query(queries: Array): cst.QueryMatchIterator; - } - export class Query { - static parse(text: string): Query; - } - export class QueryMatchIterator { - next(): QueryMatch | null; - } -} -export declare namespace parser { - export class Parser { - constructor(version: string); - get version(): string; - static supportedVersions(): Array; - static rootKind(): cst.NonterminalKind; - parse(kind: cst.NonterminalKind, input: string): parser.ParseOutput; - } - export class ParseError { - severity(): diagnostic.Severity; - textRange(): cst.TextRange; - message(): string; - } - export class ParseOutput { - tree(): cst.Node; - errors(): Array; - get isValid(): boolean; - /** Creates a cursor that starts at the root of the parse tree. */ - createTreeCursor(): cst.Cursor; - } -} -export declare namespace diagnostic { - /** - * Severity of the compiler diagnostic. - * - * Explicitly compatible with the LSP protocol. - */ - export enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, - } - /** A compiler diagnostic that can be rendered to a user. */ - export class Diagnostic { - /** The severity of this diagnostic. */ - severity(): Severity; - /** The character range of the source that this diagnostic applies to. */ - textRange(): cst.TextRange; - /** The primary message associated with this diagnostic. */ - message(): string; - } -} -export declare namespace ast_internal { - export function selectSequence(node: cst.NonterminalNode): Array; - export function selectChoice(node: cst.NonterminalNode): cst.Node; - export function selectRepeated(node: cst.NonterminalNode): Array; - export function selectSeparated(node: cst.NonterminalNode): [Array, Array]; -} - -export namespace cst { - export type Node = TerminalNode | NonterminalNode; -} diff --git a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.js b/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.js deleted file mode 100644 index 21264cf8e5..0000000000 --- a/crates/solidity/outputs/npm/package/src/generated/napi-bindings/generated/index.js +++ /dev/null @@ -1,299 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -// @ts-nocheck - -/* tslint:disable */ -/* eslint-disable */ -/* prettier-ignore */ - -/* auto-generated by NAPI-RS */ - -const { existsSync, readFileSync } = require('fs') -const { join } = require("path"); - -const { platform, arch } = process; - -let nativeBinding = null; -let localFileExisted = false; -let loadError = null; - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== "function") { - try { - const lddPath = require("child_process").execSync("which ldd").toString().trim(); - return readFileSync(lddPath, "utf8").includes("musl"); - } catch (e) { - return true; - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header; - return !glibcVersionRuntime; - } -} - -switch (platform) { - case "android": - switch (arch) { - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.android-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm64.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-android-arm64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm": - localFileExisted = existsSync(join(__dirname, "index.android-arm-eabi.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm-eabi.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-android-arm-eabi"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Android ${arch}`); - } - break; - case "win32": - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.win32-x64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-x64-msvc.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-win32-x64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "ia32": - localFileExisted = existsSync(join(__dirname, "index.win32-ia32-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-ia32-msvc.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-win32-ia32-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.win32-arm64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-arm64-msvc.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-win32-arm64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`); - } - break; - case "darwin": - localFileExisted = existsSync(join(__dirname, "index.darwin-universal.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-universal.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-darwin-universal"); - } - break; - } catch {} - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.darwin-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-x64.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-darwin-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.darwin-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-arm64.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-darwin-arm64"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`); - } - break; - case "freebsd": - if (arch !== "x64") { - throw new Error(`Unsupported architecture on FreeBSD: ${arch}`); - } - localFileExisted = existsSync(join(__dirname, "index.freebsd-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.freebsd-x64.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-freebsd-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "linux": - switch (arch) { - case "x64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-musl.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-x64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-gnu.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-x64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-musl.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-arm64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-gnu.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-arm64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-musleabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-musleabihf.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-arm-musleabihf"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-gnueabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-gnueabihf.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-arm-gnueabihf"); - } - } catch (e) { - loadError = e; - } - } - break; - case "riscv64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-musl.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-riscv64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-gnu.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-riscv64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "s390x": - localFileExisted = existsSync(join(__dirname, "index.linux-s390x-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-s390x-gnu.node"); - } else { - nativeBinding = require("@nomicfoundation/slang-linux-s390x-gnu"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`); - } - break; - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); -} - -if (!nativeBinding) { - if (loadError) { - throw loadError; - } - throw new Error(`Failed to load native binding`); -} - -const { cst, parser, diagnostic, ast_internal } = nativeBinding; - -module.exports.cst = cst; -module.exports.parser = parser; -module.exports.diagnostic = diagnostic; -module.exports.ast_internal = ast_internal; diff --git a/crates/testlang/outputs/npm/package/src/generated/parser/index.ts b/crates/solidity/outputs/npm/package/src/generated/parser/index.mts similarity index 62% rename from crates/testlang/outputs/npm/package/src/generated/parser/index.ts rename to crates/solidity/outputs/npm/package/src/generated/parser/index.mts index f3c36eefe6..14c315bbcd 100644 --- a/crates/testlang/outputs/npm/package/src/generated/parser/index.ts +++ b/crates/solidity/outputs/npm/package/src/generated/parser/index.mts @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -import * as generated from "../napi-bindings/generated"; -import { DiagnosticInterface } from "../diagnostic"; +import * as generated from "../../../wasm/index.mjs"; export const Parser = generated.parser.Parser; export type Parser = generated.parser.Parser; @@ -9,8 +8,5 @@ export type Parser = generated.parser.Parser; export const ParseError = generated.parser.ParseError; export type ParseError = generated.parser.ParseError; -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; - export const ParseOutput = generated.parser.ParseOutput; export type ParseOutput = generated.parser.ParseOutput; diff --git a/crates/solidity/outputs/npm/package/tsconfig.json b/crates/solidity/outputs/npm/package/tsconfig.json index 473e918c1d..7b4d9a1ad1 100644 --- a/crates/solidity/outputs/npm/package/tsconfig.json +++ b/crates/solidity/outputs/npm/package/tsconfig.json @@ -1,17 +1,9 @@ { "extends": "../../../../../tsconfig.json", - "include": ["./src/**/*.ts"], + "include": ["./**/*"], "compilerOptions": { - /* Modules */ - "module": "CommonJS", - "moduleResolution": "Node", - "rootDir": "./src/generated", - - /* Language and Environment */ - "target": "ES2016", - /* Projects */ "composite": true, "incremental": true, diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts new file mode 100644 index 0000000000..138e7f7f89 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts @@ -0,0 +1,16 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangAst { + export { Selectors }; +} +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalNode } from "./nomic-foundation-slang-cst.js"; +export { NonterminalNode }; + +export class Selectors { + static sequence(node: NonterminalNode): (Node | undefined)[]; + static choice(node: NonterminalNode): Node; + static repeated(node: NonterminalNode): Node[]; + static separated(node: NonterminalNode): Node[][]; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts new file mode 100644 index 0000000000..10e4f5e554 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts @@ -0,0 +1,849 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangCst { + export { TerminalKindExtensions }; + export { NonterminalNode }; + export { TerminalNode }; + export { Cursor }; + export { Query }; + export { QueryMatchIterator }; + export { NonterminalKind }; + export { TerminalKind }; + export { EdgeLabel }; + export { Node }; + export { NodeVariant }; +} +export declare enum NonterminalKind { + AbicoderPragma = "AbicoderPragma", + AdditiveExpression = "AdditiveExpression", + AddressType = "AddressType", + AndExpression = "AndExpression", + ArgumentsDeclaration = "ArgumentsDeclaration", + ArrayExpression = "ArrayExpression", + ArrayTypeName = "ArrayTypeName", + ArrayValues = "ArrayValues", + AssemblyFlags = "AssemblyFlags", + AssemblyFlagsDeclaration = "AssemblyFlagsDeclaration", + AssemblyStatement = "AssemblyStatement", + AssignmentExpression = "AssignmentExpression", + BitwiseAndExpression = "BitwiseAndExpression", + BitwiseOrExpression = "BitwiseOrExpression", + BitwiseXorExpression = "BitwiseXorExpression", + Block = "Block", + BreakStatement = "BreakStatement", + CallOptions = "CallOptions", + CallOptionsExpression = "CallOptionsExpression", + CatchClause = "CatchClause", + CatchClauseError = "CatchClauseError", + CatchClauses = "CatchClauses", + ComparisonExpression = "ComparisonExpression", + ConditionalExpression = "ConditionalExpression", + ConstantDefinition = "ConstantDefinition", + ConstructorAttribute = "ConstructorAttribute", + ConstructorAttributes = "ConstructorAttributes", + ConstructorDefinition = "ConstructorDefinition", + ContinueStatement = "ContinueStatement", + ContractDefinition = "ContractDefinition", + ContractMember = "ContractMember", + ContractMembers = "ContractMembers", + DecimalNumberExpression = "DecimalNumberExpression", + DoWhileStatement = "DoWhileStatement", + ElementaryType = "ElementaryType", + ElseBranch = "ElseBranch", + EmitStatement = "EmitStatement", + EnumDefinition = "EnumDefinition", + EnumMembers = "EnumMembers", + EqualityExpression = "EqualityExpression", + ErrorDefinition = "ErrorDefinition", + ErrorParameter = "ErrorParameter", + ErrorParameters = "ErrorParameters", + ErrorParametersDeclaration = "ErrorParametersDeclaration", + EventDefinition = "EventDefinition", + EventParameter = "EventParameter", + EventParameters = "EventParameters", + EventParametersDeclaration = "EventParametersDeclaration", + ExperimentalFeature = "ExperimentalFeature", + ExperimentalPragma = "ExperimentalPragma", + ExponentiationExpression = "ExponentiationExpression", + Expression = "Expression", + ExpressionStatement = "ExpressionStatement", + FallbackFunctionAttribute = "FallbackFunctionAttribute", + FallbackFunctionAttributes = "FallbackFunctionAttributes", + FallbackFunctionDefinition = "FallbackFunctionDefinition", + ForStatement = "ForStatement", + ForStatementCondition = "ForStatementCondition", + ForStatementInitialization = "ForStatementInitialization", + FunctionAttribute = "FunctionAttribute", + FunctionAttributes = "FunctionAttributes", + FunctionBody = "FunctionBody", + FunctionCallExpression = "FunctionCallExpression", + FunctionDefinition = "FunctionDefinition", + FunctionName = "FunctionName", + FunctionType = "FunctionType", + FunctionTypeAttribute = "FunctionTypeAttribute", + FunctionTypeAttributes = "FunctionTypeAttributes", + HexNumberExpression = "HexNumberExpression", + HexStringLiteral = "HexStringLiteral", + HexStringLiterals = "HexStringLiterals", + IdentifierPath = "IdentifierPath", + IfStatement = "IfStatement", + ImportAlias = "ImportAlias", + ImportClause = "ImportClause", + ImportDeconstruction = "ImportDeconstruction", + ImportDeconstructionSymbol = "ImportDeconstructionSymbol", + ImportDeconstructionSymbols = "ImportDeconstructionSymbols", + ImportDirective = "ImportDirective", + IndexAccessEnd = "IndexAccessEnd", + IndexAccessExpression = "IndexAccessExpression", + InheritanceSpecifier = "InheritanceSpecifier", + InheritanceType = "InheritanceType", + InheritanceTypes = "InheritanceTypes", + InterfaceDefinition = "InterfaceDefinition", + InterfaceMembers = "InterfaceMembers", + LibraryDefinition = "LibraryDefinition", + LibraryMembers = "LibraryMembers", + MappingKey = "MappingKey", + MappingKeyType = "MappingKeyType", + MappingType = "MappingType", + MappingValue = "MappingValue", + MemberAccessExpression = "MemberAccessExpression", + ModifierAttribute = "ModifierAttribute", + ModifierAttributes = "ModifierAttributes", + ModifierDefinition = "ModifierDefinition", + ModifierInvocation = "ModifierInvocation", + MultiplicativeExpression = "MultiplicativeExpression", + NamedArgument = "NamedArgument", + NamedArgumentGroup = "NamedArgumentGroup", + NamedArguments = "NamedArguments", + NamedArgumentsDeclaration = "NamedArgumentsDeclaration", + NamedImport = "NamedImport", + NewExpression = "NewExpression", + NumberUnit = "NumberUnit", + OrExpression = "OrExpression", + OverridePaths = "OverridePaths", + OverridePathsDeclaration = "OverridePathsDeclaration", + OverrideSpecifier = "OverrideSpecifier", + Parameter = "Parameter", + Parameters = "Parameters", + ParametersDeclaration = "ParametersDeclaration", + PathImport = "PathImport", + PositionalArguments = "PositionalArguments", + PositionalArgumentsDeclaration = "PositionalArgumentsDeclaration", + PostfixExpression = "PostfixExpression", + Pragma = "Pragma", + PragmaDirective = "PragmaDirective", + PrefixExpression = "PrefixExpression", + ReceiveFunctionAttribute = "ReceiveFunctionAttribute", + ReceiveFunctionAttributes = "ReceiveFunctionAttributes", + ReceiveFunctionDefinition = "ReceiveFunctionDefinition", + ReturnStatement = "ReturnStatement", + ReturnsDeclaration = "ReturnsDeclaration", + RevertStatement = "RevertStatement", + ShiftExpression = "ShiftExpression", + SimpleVersionLiteral = "SimpleVersionLiteral", + SourceUnit = "SourceUnit", + SourceUnitMember = "SourceUnitMember", + SourceUnitMembers = "SourceUnitMembers", + StateVariableAttribute = "StateVariableAttribute", + StateVariableAttributes = "StateVariableAttributes", + StateVariableDefinition = "StateVariableDefinition", + StateVariableDefinitionValue = "StateVariableDefinitionValue", + Statement = "Statement", + Statements = "Statements", + StorageLocation = "StorageLocation", + StringExpression = "StringExpression", + StringLiteral = "StringLiteral", + StringLiterals = "StringLiterals", + StructDefinition = "StructDefinition", + StructMember = "StructMember", + StructMembers = "StructMembers", + ThrowStatement = "ThrowStatement", + TryStatement = "TryStatement", + TupleDeconstructionElement = "TupleDeconstructionElement", + TupleDeconstructionElements = "TupleDeconstructionElements", + TupleDeconstructionStatement = "TupleDeconstructionStatement", + TupleExpression = "TupleExpression", + TupleMember = "TupleMember", + TupleValue = "TupleValue", + TupleValues = "TupleValues", + TypeExpression = "TypeExpression", + TypeName = "TypeName", + TypedTupleMember = "TypedTupleMember", + UncheckedBlock = "UncheckedBlock", + UnicodeStringLiteral = "UnicodeStringLiteral", + UnicodeStringLiterals = "UnicodeStringLiterals", + UnnamedFunctionAttribute = "UnnamedFunctionAttribute", + UnnamedFunctionAttributes = "UnnamedFunctionAttributes", + UnnamedFunctionDefinition = "UnnamedFunctionDefinition", + UntypedTupleMember = "UntypedTupleMember", + UserDefinedValueTypeDefinition = "UserDefinedValueTypeDefinition", + UsingAlias = "UsingAlias", + UsingClause = "UsingClause", + UsingDeconstruction = "UsingDeconstruction", + UsingDeconstructionSymbol = "UsingDeconstructionSymbol", + UsingDeconstructionSymbols = "UsingDeconstructionSymbols", + UsingDirective = "UsingDirective", + UsingOperator = "UsingOperator", + UsingTarget = "UsingTarget", + VariableDeclarationStatement = "VariableDeclarationStatement", + VariableDeclarationType = "VariableDeclarationType", + VariableDeclarationValue = "VariableDeclarationValue", + VersionExpression = "VersionExpression", + VersionExpressionSet = "VersionExpressionSet", + VersionExpressionSets = "VersionExpressionSets", + VersionLiteral = "VersionLiteral", + VersionOperator = "VersionOperator", + VersionPragma = "VersionPragma", + VersionRange = "VersionRange", + VersionTerm = "VersionTerm", + WhileStatement = "WhileStatement", + YulArguments = "YulArguments", + YulAssignmentOperator = "YulAssignmentOperator", + YulBlock = "YulBlock", + YulBreakStatement = "YulBreakStatement", + YulBuiltInFunction = "YulBuiltInFunction", + YulColonAndEqual = "YulColonAndEqual", + YulContinueStatement = "YulContinueStatement", + YulDefaultCase = "YulDefaultCase", + YulEqualAndColon = "YulEqualAndColon", + YulExpression = "YulExpression", + YulForStatement = "YulForStatement", + YulFunctionCallExpression = "YulFunctionCallExpression", + YulFunctionDefinition = "YulFunctionDefinition", + YulIfStatement = "YulIfStatement", + YulLabel = "YulLabel", + YulLeaveStatement = "YulLeaveStatement", + YulLiteral = "YulLiteral", + YulParameters = "YulParameters", + YulParametersDeclaration = "YulParametersDeclaration", + YulPath = "YulPath", + YulPathComponent = "YulPathComponent", + YulPaths = "YulPaths", + YulReturnsDeclaration = "YulReturnsDeclaration", + YulStackAssignmentOperator = "YulStackAssignmentOperator", + YulStackAssignmentStatement = "YulStackAssignmentStatement", + YulStatement = "YulStatement", + YulStatements = "YulStatements", + YulSwitchCase = "YulSwitchCase", + YulSwitchCases = "YulSwitchCases", + YulSwitchStatement = "YulSwitchStatement", + YulValueCase = "YulValueCase", + YulVariableAssignmentStatement = "YulVariableAssignmentStatement", + YulVariableDeclarationStatement = "YulVariableDeclarationStatement", + YulVariableDeclarationValue = "YulVariableDeclarationValue", + YulVariableNames = "YulVariableNames", +} +export declare enum TerminalKind { + Unrecognized = "Unrecognized", + Missing = "Missing", + AbicoderKeyword = "AbicoderKeyword", + AbstractKeyword = "AbstractKeyword", + AddressKeyword = "AddressKeyword", + AfterKeyword = "AfterKeyword", + AliasKeyword = "AliasKeyword", + Ampersand = "Ampersand", + AmpersandAmpersand = "AmpersandAmpersand", + AmpersandEqual = "AmpersandEqual", + AnonymousKeyword = "AnonymousKeyword", + ApplyKeyword = "ApplyKeyword", + AsKeyword = "AsKeyword", + AssemblyKeyword = "AssemblyKeyword", + Asterisk = "Asterisk", + AsteriskAsterisk = "AsteriskAsterisk", + AsteriskEqual = "AsteriskEqual", + AutoKeyword = "AutoKeyword", + Bang = "Bang", + BangEqual = "BangEqual", + Bar = "Bar", + BarBar = "BarBar", + BarEqual = "BarEqual", + BoolKeyword = "BoolKeyword", + BreakKeyword = "BreakKeyword", + ByteKeyword = "ByteKeyword", + BytesKeyword = "BytesKeyword", + CallDataKeyword = "CallDataKeyword", + Caret = "Caret", + CaretEqual = "CaretEqual", + CaseKeyword = "CaseKeyword", + CatchKeyword = "CatchKeyword", + CloseBrace = "CloseBrace", + CloseBracket = "CloseBracket", + CloseParen = "CloseParen", + Colon = "Colon", + ColonEqual = "ColonEqual", + Comma = "Comma", + ConstantKeyword = "ConstantKeyword", + ConstructorKeyword = "ConstructorKeyword", + ContinueKeyword = "ContinueKeyword", + ContractKeyword = "ContractKeyword", + CopyOfKeyword = "CopyOfKeyword", + DaysKeyword = "DaysKeyword", + DecimalLiteral = "DecimalLiteral", + DefaultKeyword = "DefaultKeyword", + DefineKeyword = "DefineKeyword", + DeleteKeyword = "DeleteKeyword", + DoKeyword = "DoKeyword", + DoubleQuotedHexStringLiteral = "DoubleQuotedHexStringLiteral", + DoubleQuotedStringLiteral = "DoubleQuotedStringLiteral", + DoubleQuotedUnicodeStringLiteral = "DoubleQuotedUnicodeStringLiteral", + DoubleQuotedVersionLiteral = "DoubleQuotedVersionLiteral", + ElseKeyword = "ElseKeyword", + EmitKeyword = "EmitKeyword", + EndOfLine = "EndOfLine", + EnumKeyword = "EnumKeyword", + Equal = "Equal", + EqualColon = "EqualColon", + EqualEqual = "EqualEqual", + EqualGreaterThan = "EqualGreaterThan", + ErrorKeyword = "ErrorKeyword", + EtherKeyword = "EtherKeyword", + EventKeyword = "EventKeyword", + ExperimentalKeyword = "ExperimentalKeyword", + ExternalKeyword = "ExternalKeyword", + FallbackKeyword = "FallbackKeyword", + FalseKeyword = "FalseKeyword", + FinalKeyword = "FinalKeyword", + FinneyKeyword = "FinneyKeyword", + FixedKeyword = "FixedKeyword", + ForKeyword = "ForKeyword", + FromKeyword = "FromKeyword", + FunctionKeyword = "FunctionKeyword", + GlobalKeyword = "GlobalKeyword", + GreaterThan = "GreaterThan", + GreaterThanEqual = "GreaterThanEqual", + GreaterThanGreaterThan = "GreaterThanGreaterThan", + GreaterThanGreaterThanEqual = "GreaterThanGreaterThanEqual", + GreaterThanGreaterThanGreaterThan = "GreaterThanGreaterThanGreaterThan", + GreaterThanGreaterThanGreaterThanEqual = "GreaterThanGreaterThanGreaterThanEqual", + GweiKeyword = "GweiKeyword", + HexKeyword = "HexKeyword", + HexLiteral = "HexLiteral", + HoursKeyword = "HoursKeyword", + Identifier = "Identifier", + IfKeyword = "IfKeyword", + ImmutableKeyword = "ImmutableKeyword", + ImplementsKeyword = "ImplementsKeyword", + ImportKeyword = "ImportKeyword", + InKeyword = "InKeyword", + IndexedKeyword = "IndexedKeyword", + InlineKeyword = "InlineKeyword", + IntKeyword = "IntKeyword", + InterfaceKeyword = "InterfaceKeyword", + InternalKeyword = "InternalKeyword", + IsKeyword = "IsKeyword", + LessThan = "LessThan", + LessThanEqual = "LessThanEqual", + LessThanLessThan = "LessThanLessThan", + LessThanLessThanEqual = "LessThanLessThanEqual", + LetKeyword = "LetKeyword", + LibraryKeyword = "LibraryKeyword", + MacroKeyword = "MacroKeyword", + MappingKeyword = "MappingKeyword", + MatchKeyword = "MatchKeyword", + MemoryKeyword = "MemoryKeyword", + Minus = "Minus", + MinusEqual = "MinusEqual", + MinusGreaterThan = "MinusGreaterThan", + MinusMinus = "MinusMinus", + MinutesKeyword = "MinutesKeyword", + ModifierKeyword = "ModifierKeyword", + MultiLineComment = "MultiLineComment", + MultiLineNatSpecComment = "MultiLineNatSpecComment", + MutableKeyword = "MutableKeyword", + NewKeyword = "NewKeyword", + NullKeyword = "NullKeyword", + OfKeyword = "OfKeyword", + OpenBrace = "OpenBrace", + OpenBracket = "OpenBracket", + OpenParen = "OpenParen", + OverrideKeyword = "OverrideKeyword", + PartialKeyword = "PartialKeyword", + PayableKeyword = "PayableKeyword", + Percent = "Percent", + PercentEqual = "PercentEqual", + Period = "Period", + Plus = "Plus", + PlusEqual = "PlusEqual", + PlusPlus = "PlusPlus", + PragmaKeyword = "PragmaKeyword", + PrivateKeyword = "PrivateKeyword", + PromiseKeyword = "PromiseKeyword", + PublicKeyword = "PublicKeyword", + PureKeyword = "PureKeyword", + QuestionMark = "QuestionMark", + ReceiveKeyword = "ReceiveKeyword", + ReferenceKeyword = "ReferenceKeyword", + RelocatableKeyword = "RelocatableKeyword", + ReturnKeyword = "ReturnKeyword", + ReturnsKeyword = "ReturnsKeyword", + RevertKeyword = "RevertKeyword", + SealedKeyword = "SealedKeyword", + SecondsKeyword = "SecondsKeyword", + Semicolon = "Semicolon", + SingleLineComment = "SingleLineComment", + SingleLineNatSpecComment = "SingleLineNatSpecComment", + SingleQuotedHexStringLiteral = "SingleQuotedHexStringLiteral", + SingleQuotedStringLiteral = "SingleQuotedStringLiteral", + SingleQuotedUnicodeStringLiteral = "SingleQuotedUnicodeStringLiteral", + SingleQuotedVersionLiteral = "SingleQuotedVersionLiteral", + SizeOfKeyword = "SizeOfKeyword", + Slash = "Slash", + SlashEqual = "SlashEqual", + SolidityKeyword = "SolidityKeyword", + StaticKeyword = "StaticKeyword", + StorageKeyword = "StorageKeyword", + StringKeyword = "StringKeyword", + StructKeyword = "StructKeyword", + SupportsKeyword = "SupportsKeyword", + SwitchKeyword = "SwitchKeyword", + SzaboKeyword = "SzaboKeyword", + ThrowKeyword = "ThrowKeyword", + Tilde = "Tilde", + TransientKeyword = "TransientKeyword", + TrueKeyword = "TrueKeyword", + TryKeyword = "TryKeyword", + TypeDefKeyword = "TypeDefKeyword", + TypeKeyword = "TypeKeyword", + TypeOfKeyword = "TypeOfKeyword", + UfixedKeyword = "UfixedKeyword", + UintKeyword = "UintKeyword", + UncheckedKeyword = "UncheckedKeyword", + UsingKeyword = "UsingKeyword", + VarKeyword = "VarKeyword", + VersionSpecifier = "VersionSpecifier", + ViewKeyword = "ViewKeyword", + VirtualKeyword = "VirtualKeyword", + WeeksKeyword = "WeeksKeyword", + WeiKeyword = "WeiKeyword", + WhileKeyword = "WhileKeyword", + Whitespace = "Whitespace", + YearsKeyword = "YearsKeyword", + YulAbstractKeyword = "YulAbstractKeyword", + YulAddKeyword = "YulAddKeyword", + YulAddModKeyword = "YulAddModKeyword", + YulAddressKeyword = "YulAddressKeyword", + YulAfterKeyword = "YulAfterKeyword", + YulAliasKeyword = "YulAliasKeyword", + YulAndKeyword = "YulAndKeyword", + YulAnonymousKeyword = "YulAnonymousKeyword", + YulApplyKeyword = "YulApplyKeyword", + YulAsKeyword = "YulAsKeyword", + YulAssemblyKeyword = "YulAssemblyKeyword", + YulAutoKeyword = "YulAutoKeyword", + YulBalanceKeyword = "YulBalanceKeyword", + YulBaseFeeKeyword = "YulBaseFeeKeyword", + YulBlobBaseFeeKeyword = "YulBlobBaseFeeKeyword", + YulBlobHashKeyword = "YulBlobHashKeyword", + YulBlockHashKeyword = "YulBlockHashKeyword", + YulBoolKeyword = "YulBoolKeyword", + YulBreakKeyword = "YulBreakKeyword", + YulByteKeyword = "YulByteKeyword", + YulBytesKeyword = "YulBytesKeyword", + YulCallCodeKeyword = "YulCallCodeKeyword", + YulCallDataCopyKeyword = "YulCallDataCopyKeyword", + YulCallDataKeyword = "YulCallDataKeyword", + YulCallDataLoadKeyword = "YulCallDataLoadKeyword", + YulCallDataSizeKeyword = "YulCallDataSizeKeyword", + YulCallKeyword = "YulCallKeyword", + YulCallValueKeyword = "YulCallValueKeyword", + YulCallerKeyword = "YulCallerKeyword", + YulCaseKeyword = "YulCaseKeyword", + YulCatchKeyword = "YulCatchKeyword", + YulChainIdKeyword = "YulChainIdKeyword", + YulCoinBaseKeyword = "YulCoinBaseKeyword", + YulConstantKeyword = "YulConstantKeyword", + YulConstructorKeyword = "YulConstructorKeyword", + YulContinueKeyword = "YulContinueKeyword", + YulContractKeyword = "YulContractKeyword", + YulCopyOfKeyword = "YulCopyOfKeyword", + YulCreate2Keyword = "YulCreate2Keyword", + YulCreateKeyword = "YulCreateKeyword", + YulDaysKeyword = "YulDaysKeyword", + YulDecimalLiteral = "YulDecimalLiteral", + YulDefaultKeyword = "YulDefaultKeyword", + YulDefineKeyword = "YulDefineKeyword", + YulDelegateCallKeyword = "YulDelegateCallKeyword", + YulDeleteKeyword = "YulDeleteKeyword", + YulDifficultyKeyword = "YulDifficultyKeyword", + YulDivKeyword = "YulDivKeyword", + YulDoKeyword = "YulDoKeyword", + YulElseKeyword = "YulElseKeyword", + YulEmitKeyword = "YulEmitKeyword", + YulEnumKeyword = "YulEnumKeyword", + YulEqKeyword = "YulEqKeyword", + YulEtherKeyword = "YulEtherKeyword", + YulEventKeyword = "YulEventKeyword", + YulExpKeyword = "YulExpKeyword", + YulExtCodeCopyKeyword = "YulExtCodeCopyKeyword", + YulExtCodeHashKeyword = "YulExtCodeHashKeyword", + YulExtCodeSizeKeyword = "YulExtCodeSizeKeyword", + YulExternalKeyword = "YulExternalKeyword", + YulFallbackKeyword = "YulFallbackKeyword", + YulFalseKeyword = "YulFalseKeyword", + YulFinalKeyword = "YulFinalKeyword", + YulFinneyKeyword = "YulFinneyKeyword", + YulFixedKeyword = "YulFixedKeyword", + YulForKeyword = "YulForKeyword", + YulFunctionKeyword = "YulFunctionKeyword", + YulGasKeyword = "YulGasKeyword", + YulGasLimitKeyword = "YulGasLimitKeyword", + YulGasPriceKeyword = "YulGasPriceKeyword", + YulGtKeyword = "YulGtKeyword", + YulGweiKeyword = "YulGweiKeyword", + YulHexKeyword = "YulHexKeyword", + YulHexLiteral = "YulHexLiteral", + YulHoursKeyword = "YulHoursKeyword", + YulIdentifier = "YulIdentifier", + YulIfKeyword = "YulIfKeyword", + YulImmutableKeyword = "YulImmutableKeyword", + YulImplementsKeyword = "YulImplementsKeyword", + YulImportKeyword = "YulImportKeyword", + YulInKeyword = "YulInKeyword", + YulIndexedKeyword = "YulIndexedKeyword", + YulInlineKeyword = "YulInlineKeyword", + YulIntKeyword = "YulIntKeyword", + YulInterfaceKeyword = "YulInterfaceKeyword", + YulInternalKeyword = "YulInternalKeyword", + YulInvalidKeyword = "YulInvalidKeyword", + YulIsKeyword = "YulIsKeyword", + YulIsZeroKeyword = "YulIsZeroKeyword", + YulKeccak256Keyword = "YulKeccak256Keyword", + YulLeaveKeyword = "YulLeaveKeyword", + YulLetKeyword = "YulLetKeyword", + YulLibraryKeyword = "YulLibraryKeyword", + YulLog0Keyword = "YulLog0Keyword", + YulLog1Keyword = "YulLog1Keyword", + YulLog2Keyword = "YulLog2Keyword", + YulLog3Keyword = "YulLog3Keyword", + YulLog4Keyword = "YulLog4Keyword", + YulLtKeyword = "YulLtKeyword", + YulMcopyKeyword = "YulMcopyKeyword", + YulMloadKeyword = "YulMloadKeyword", + YulMsizeKeyword = "YulMsizeKeyword", + YulMstore8Keyword = "YulMstore8Keyword", + YulMstoreKeyword = "YulMstoreKeyword", + YulMacroKeyword = "YulMacroKeyword", + YulMappingKeyword = "YulMappingKeyword", + YulMatchKeyword = "YulMatchKeyword", + YulMemoryKeyword = "YulMemoryKeyword", + YulMinutesKeyword = "YulMinutesKeyword", + YulModKeyword = "YulModKeyword", + YulModifierKeyword = "YulModifierKeyword", + YulMulKeyword = "YulMulKeyword", + YulMulModKeyword = "YulMulModKeyword", + YulMutableKeyword = "YulMutableKeyword", + YulNewKeyword = "YulNewKeyword", + YulNotKeyword = "YulNotKeyword", + YulNullKeyword = "YulNullKeyword", + YulNumberKeyword = "YulNumberKeyword", + YulOfKeyword = "YulOfKeyword", + YulOrKeyword = "YulOrKeyword", + YulOriginKeyword = "YulOriginKeyword", + YulOverrideKeyword = "YulOverrideKeyword", + YulPartialKeyword = "YulPartialKeyword", + YulPayableKeyword = "YulPayableKeyword", + YulPopKeyword = "YulPopKeyword", + YulPragmaKeyword = "YulPragmaKeyword", + YulPrevRandaoKeyword = "YulPrevRandaoKeyword", + YulPrivateKeyword = "YulPrivateKeyword", + YulPromiseKeyword = "YulPromiseKeyword", + YulPublicKeyword = "YulPublicKeyword", + YulPureKeyword = "YulPureKeyword", + YulReceiveKeyword = "YulReceiveKeyword", + YulReferenceKeyword = "YulReferenceKeyword", + YulRelocatableKeyword = "YulRelocatableKeyword", + YulReturnDataCopyKeyword = "YulReturnDataCopyKeyword", + YulReturnDataSizeKeyword = "YulReturnDataSizeKeyword", + YulReturnKeyword = "YulReturnKeyword", + YulReturnsKeyword = "YulReturnsKeyword", + YulRevertKeyword = "YulRevertKeyword", + YulSdivKeyword = "YulSdivKeyword", + YulSloadKeyword = "YulSloadKeyword", + YulSmodKeyword = "YulSmodKeyword", + YulSstoreKeyword = "YulSstoreKeyword", + YulSarKeyword = "YulSarKeyword", + YulSealedKeyword = "YulSealedKeyword", + YulSecondsKeyword = "YulSecondsKeyword", + YulSelfBalanceKeyword = "YulSelfBalanceKeyword", + YulSelfDestructKeyword = "YulSelfDestructKeyword", + YulSgtKeyword = "YulSgtKeyword", + YulSha3Keyword = "YulSha3Keyword", + YulShlKeyword = "YulShlKeyword", + YulShrKeyword = "YulShrKeyword", + YulSignExtendKeyword = "YulSignExtendKeyword", + YulSizeOfKeyword = "YulSizeOfKeyword", + YulSltKeyword = "YulSltKeyword", + YulStaticCallKeyword = "YulStaticCallKeyword", + YulStaticKeyword = "YulStaticKeyword", + YulStopKeyword = "YulStopKeyword", + YulStorageKeyword = "YulStorageKeyword", + YulStringKeyword = "YulStringKeyword", + YulStructKeyword = "YulStructKeyword", + YulSubKeyword = "YulSubKeyword", + YulSuicideKeyword = "YulSuicideKeyword", + YulSupportsKeyword = "YulSupportsKeyword", + YulSwitchKeyword = "YulSwitchKeyword", + YulSzaboKeyword = "YulSzaboKeyword", + YulTloadKeyword = "YulTloadKeyword", + YulTstoreKeyword = "YulTstoreKeyword", + YulThrowKeyword = "YulThrowKeyword", + YulTimestampKeyword = "YulTimestampKeyword", + YulTrueKeyword = "YulTrueKeyword", + YulTryKeyword = "YulTryKeyword", + YulTypeDefKeyword = "YulTypeDefKeyword", + YulTypeKeyword = "YulTypeKeyword", + YulTypeOfKeyword = "YulTypeOfKeyword", + YulUfixedKeyword = "YulUfixedKeyword", + YulUintKeyword = "YulUintKeyword", + YulUncheckedKeyword = "YulUncheckedKeyword", + YulUsingKeyword = "YulUsingKeyword", + YulVarKeyword = "YulVarKeyword", + YulViewKeyword = "YulViewKeyword", + YulVirtualKeyword = "YulVirtualKeyword", + YulWeeksKeyword = "YulWeeksKeyword", + YulWeiKeyword = "YulWeiKeyword", + YulWhileKeyword = "YulWhileKeyword", + YulXorKeyword = "YulXorKeyword", + YulYearsKeyword = "YulYearsKeyword", +} +export declare enum EdgeLabel { + Item = "Item", + Variant = "Variant", + Separator = "Separator", + Operand = "Operand", + LeftOperand = "LeftOperand", + RightOperand = "RightOperand", + LeadingTrivia = "LeadingTrivia", + TrailingTrivia = "TrailingTrivia", + AbicoderKeyword = "AbicoderKeyword", + AbstractKeyword = "AbstractKeyword", + AddressKeyword = "AddressKeyword", + Alias = "Alias", + AnonymousKeyword = "AnonymousKeyword", + Arguments = "Arguments", + AsKeyword = "AsKeyword", + AssemblyKeyword = "AssemblyKeyword", + Assignment = "Assignment", + Asterisk = "Asterisk", + Attributes = "Attributes", + Block = "Block", + Body = "Body", + BreakKeyword = "BreakKeyword", + CaseKeyword = "CaseKeyword", + Cases = "Cases", + CatchClauses = "CatchClauses", + CatchKeyword = "CatchKeyword", + Clause = "Clause", + CloseBrace = "CloseBrace", + CloseBracket = "CloseBracket", + CloseParen = "CloseParen", + Colon = "Colon", + Condition = "Condition", + ConstantKeyword = "ConstantKeyword", + ConstructorKeyword = "ConstructorKeyword", + ContinueKeyword = "ContinueKeyword", + ContractKeyword = "ContractKeyword", + DefaultKeyword = "DefaultKeyword", + DoKeyword = "DoKeyword", + Elements = "Elements", + ElseBranch = "ElseBranch", + ElseKeyword = "ElseKeyword", + EmitKeyword = "EmitKeyword", + End = "End", + EnumKeyword = "EnumKeyword", + Equal = "Equal", + EqualGreaterThan = "EqualGreaterThan", + Error = "Error", + ErrorKeyword = "ErrorKeyword", + Event = "Event", + EventKeyword = "EventKeyword", + ExperimentalKeyword = "ExperimentalKeyword", + Expression = "Expression", + FallbackKeyword = "FallbackKeyword", + FalseExpression = "FalseExpression", + Feature = "Feature", + Flags = "Flags", + ForKeyword = "ForKeyword", + FromKeyword = "FromKeyword", + FunctionKeyword = "FunctionKeyword", + GlobalKeyword = "GlobalKeyword", + Identifier = "Identifier", + IfKeyword = "IfKeyword", + ImportKeyword = "ImportKeyword", + Index = "Index", + IndexedKeyword = "IndexedKeyword", + Inheritance = "Inheritance", + Initialization = "Initialization", + InterfaceKeyword = "InterfaceKeyword", + IsKeyword = "IsKeyword", + Items = "Items", + Iterator = "Iterator", + KeyType = "KeyType", + Label = "Label", + LeaveKeyword = "LeaveKeyword", + LetKeyword = "LetKeyword", + LibraryKeyword = "LibraryKeyword", + Literal = "Literal", + MappingKeyword = "MappingKeyword", + Member = "Member", + Members = "Members", + Minus = "Minus", + MinusGreaterThan = "MinusGreaterThan", + ModifierKeyword = "ModifierKeyword", + Name = "Name", + NewKeyword = "NewKeyword", + OpenBrace = "OpenBrace", + OpenBracket = "OpenBracket", + OpenParen = "OpenParen", + Operator = "Operator", + Options = "Options", + Overridden = "Overridden", + OverrideKeyword = "OverrideKeyword", + Parameters = "Parameters", + Path = "Path", + Paths = "Paths", + PayableKeyword = "PayableKeyword", + Period = "Period", + Pragma = "Pragma", + PragmaKeyword = "PragmaKeyword", + QuestionMark = "QuestionMark", + ReceiveKeyword = "ReceiveKeyword", + ReturnKeyword = "ReturnKeyword", + Returns = "Returns", + ReturnsKeyword = "ReturnsKeyword", + RevertKeyword = "RevertKeyword", + Semicolon = "Semicolon", + Sets = "Sets", + SolidityKeyword = "SolidityKeyword", + Start = "Start", + Statements = "Statements", + StorageLocation = "StorageLocation", + StructKeyword = "StructKeyword", + SwitchKeyword = "SwitchKeyword", + Symbols = "Symbols", + Target = "Target", + ThrowKeyword = "ThrowKeyword", + TrueExpression = "TrueExpression", + TryKeyword = "TryKeyword", + TypeKeyword = "TypeKeyword", + TypeName = "TypeName", + Types = "Types", + UncheckedKeyword = "UncheckedKeyword", + Unit = "Unit", + UsingKeyword = "UsingKeyword", + Value = "Value", + ValueType = "ValueType", + VarKeyword = "VarKeyword", + Variable = "Variable", + VariableType = "VariableType", + Variables = "Variables", + Version = "Version", + WhileKeyword = "WhileKeyword", +} +export type Node = NonterminalNode | TerminalNode; +export enum NodeVariant { + NonterminalNode = "NonterminalNode", + TerminalNode = "TerminalNode", +} +export interface Edge { + label?: EdgeLabel; + node: Node; +} +export interface QueryError { + message: string; + line: number; + column: number; +} +export interface QueryMatch { + queryNumber: number; + captures: { [key: string]: Cursor[] }; +} +export interface TextIndex { + utf8: number; + utf16: number; + line: number; + column: number; +} +export interface TextRange { + start: TextIndex; + end: TextIndex; +} + +export class Cursor { + reset(): void; + complete(): void; + isCompleted(): boolean; + clone(): Cursor; + spawn(): Cursor; + get node(): Node; + get label(): EdgeLabel | undefined; + get textOffset(): TextIndex; + get textRange(): TextRange; + get depth(): number; + get ancestors(): NonterminalNode[]; + goToNext(): boolean; + goToNextNonDescendent(): boolean; + goToPrevious(): boolean; + goToParent(): boolean; + goToFirstChild(): boolean; + goToLastChild(): boolean; + goToNthChild(childNumber: number): boolean; + goToNextSibling(): boolean; + goToPreviousSibling(): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: TerminalKind): boolean; + goToNextTerminalWithKinds(kinds: TerminalKind[]): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: NonterminalKind[]): boolean; + query(queries: Query[]): QueryMatchIterator; +} + +export class NonterminalNode { + readonly nodeVariant = NodeVariant.NonterminalNode; + + asNonterminalNode(): this; + isNonterminalNode(): this is NonterminalNode; + + asTerminalNode(): undefined; + isTerminalNode(): false; + + get id(): number; + get kind(): NonterminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; + createCursor(textOffset: TextIndex): Cursor; +} + +export class Query { + static parse(text: string): Query; +} + +export class QueryMatchIterator { + [Symbol.iterator](): Iterator; + next(): QueryMatch | undefined; +} + +export class TerminalKindExtensions { + static isTrivia(kind: TerminalKind): boolean; + static isValid(kind: TerminalKind): boolean; +} + +export class TerminalNode { + readonly nodeVariant = NodeVariant.TerminalNode; + + asTerminalNode(): this; + isTerminalNode(): this is TerminalNode; + + asNonterminalNode(): undefined; + isNonterminalNode(): false; + + get id(): number; + get kind(): TerminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts new file mode 100644 index 0000000000..c759bea9a5 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts @@ -0,0 +1,35 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangParser { + export { Parser }; + export { ParseError }; + export { ParseOutput }; +} +import type { Cursor } from "./nomic-foundation-slang-cst.js"; +export { Cursor }; +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalKind } from "./nomic-foundation-slang-cst.js"; +export { NonterminalKind }; +import type { TextRange } from "./nomic-foundation-slang-cst.js"; +export { TextRange }; + +export class ParseError { + get textRange(): TextRange; + get message(): string; +} + +export class ParseOutput { + get tree(): Node; + get errors(): ParseError[]; + isValid(): boolean; + createTreeCursor(): Cursor; +} + +export class Parser { + static rootKind(): NonterminalKind; + static supportedVersions(): string[]; + static create(version: string): Parser; + get version(): string; + parse(kind: NonterminalKind, input: string): ParseOutput; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts new file mode 100644 index 0000000000..2e7e18e20c --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts @@ -0,0 +1,5 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliEnvironment { + export function getEnvironment(): [string, string][]; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts new file mode 100644 index 0000000000..00e416f2a9 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliExit { + export function exit(status: Result): void; +} +export type Result = { tag: "ok"; val: T } | { tag: "err"; val: E }; diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts new file mode 100644 index 0000000000..58b90e29bf --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStderr { + export function getStderr(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts new file mode 100644 index 0000000000..e5f574f5bd --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdin { + export function getStdin(): InputStream; +} +import type { InputStream } from "./wasi-io-streams.js"; +export { InputStream }; diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts new file mode 100644 index 0000000000..49023013c5 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdout { + export function getStdout(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts new file mode 100644 index 0000000000..ea190faee8 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiClocksWallClock {} +export interface Datetime { + seconds: bigint; + nanoseconds: number; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts new file mode 100644 index 0000000000..7c94c88da2 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemPreopens { + export function getDirectories(): [Descriptor, string][]; +} +import type { Descriptor } from "./wasi-filesystem-types.js"; +export { Descriptor }; diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts new file mode 100644 index 0000000000..140b5f4bac --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts @@ -0,0 +1,172 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemTypes { + export { Descriptor }; + export function filesystemErrorCode(err: Error): ErrorCode | undefined; +} +export type Filesize = bigint; +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; +/** + * # Variants + * + * ## `"access"` + * + * ## `"would-block"` + * + * ## `"already"` + * + * ## `"bad-descriptor"` + * + * ## `"busy"` + * + * ## `"deadlock"` + * + * ## `"quota"` + * + * ## `"exist"` + * + * ## `"file-too-large"` + * + * ## `"illegal-byte-sequence"` + * + * ## `"in-progress"` + * + * ## `"interrupted"` + * + * ## `"invalid"` + * + * ## `"io"` + * + * ## `"is-directory"` + * + * ## `"loop"` + * + * ## `"too-many-links"` + * + * ## `"message-size"` + * + * ## `"name-too-long"` + * + * ## `"no-device"` + * + * ## `"no-entry"` + * + * ## `"no-lock"` + * + * ## `"insufficient-memory"` + * + * ## `"insufficient-space"` + * + * ## `"not-directory"` + * + * ## `"not-empty"` + * + * ## `"not-recoverable"` + * + * ## `"unsupported"` + * + * ## `"no-tty"` + * + * ## `"no-such-device"` + * + * ## `"overflow"` + * + * ## `"not-permitted"` + * + * ## `"pipe"` + * + * ## `"read-only"` + * + * ## `"invalid-seek"` + * + * ## `"text-file-busy"` + * + * ## `"cross-device"` + */ +export type ErrorCode = + | "access" + | "would-block" + | "already" + | "bad-descriptor" + | "busy" + | "deadlock" + | "quota" + | "exist" + | "file-too-large" + | "illegal-byte-sequence" + | "in-progress" + | "interrupted" + | "invalid" + | "io" + | "is-directory" + | "loop" + | "too-many-links" + | "message-size" + | "name-too-long" + | "no-device" + | "no-entry" + | "no-lock" + | "insufficient-memory" + | "insufficient-space" + | "not-directory" + | "not-empty" + | "not-recoverable" + | "unsupported" + | "no-tty" + | "no-such-device" + | "overflow" + | "not-permitted" + | "pipe" + | "read-only" + | "invalid-seek" + | "text-file-busy" + | "cross-device"; +/** + * # Variants + * + * ## `"unknown"` + * + * ## `"block-device"` + * + * ## `"character-device"` + * + * ## `"directory"` + * + * ## `"fifo"` + * + * ## `"symbolic-link"` + * + * ## `"regular-file"` + * + * ## `"socket"` + */ +export type DescriptorType = + | "unknown" + | "block-device" + | "character-device" + | "directory" + | "fifo" + | "symbolic-link" + | "regular-file" + | "socket"; +export type LinkCount = bigint; +import type { Datetime } from "./wasi-clocks-wall-clock.js"; +export { Datetime }; +export interface DescriptorStat { + type: DescriptorType; + linkCount: LinkCount; + size: Filesize; + dataAccessTimestamp?: Datetime; + dataModificationTimestamp?: Datetime; + statusChangeTimestamp?: Datetime; +} +import type { Error } from "./wasi-io-streams.js"; +export { Error }; + +export class Descriptor { + writeViaStream(offset: Filesize): OutputStream; + appendViaStream(): OutputStream; + getType(): DescriptorType; + stat(): DescriptorStat; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts new file mode 100644 index 0000000000..f52a8b4cc5 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiIoError { + export { Error }; +} + +export class Error {} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts new file mode 100644 index 0000000000..fc56e10c39 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts @@ -0,0 +1,25 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiIoStreams { + export { OutputStream }; + export { InputStream }; +} +import type { Error } from "./wasi-io-error.js"; +export { Error }; +export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed; +export interface StreamErrorLastOperationFailed { + tag: "last-operation-failed"; + val: Error; +} +export interface StreamErrorClosed { + tag: "closed"; +} + +export class InputStream {} + +export class OutputStream { + checkWrite(): bigint; + write(contents: Uint8Array): void; + blockingWriteAndFlush(contents: Uint8Array): void; + blockingFlush(): void; +} diff --git a/crates/solidity/outputs/npm/package/wasm/generated/solidity_cargo_wasm.component.d.ts b/crates/solidity/outputs/npm/package/wasm/generated/solidity_cargo_wasm.component.d.ts new file mode 100644 index 0000000000..237bb59193 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/generated/solidity_cargo_wasm.component.d.ts @@ -0,0 +1,18 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +import { WasiCliEnvironment } from "./interfaces/wasi-cli-environment.js"; +import { WasiCliExit } from "./interfaces/wasi-cli-exit.js"; +import { WasiCliStderr } from "./interfaces/wasi-cli-stderr.js"; +import { WasiCliStdin } from "./interfaces/wasi-cli-stdin.js"; +import { WasiCliStdout } from "./interfaces/wasi-cli-stdout.js"; +import { WasiClocksWallClock } from "./interfaces/wasi-clocks-wall-clock.js"; +import { WasiFilesystemPreopens } from "./interfaces/wasi-filesystem-preopens.js"; +import { WasiFilesystemTypes } from "./interfaces/wasi-filesystem-types.js"; +import { WasiIoError } from "./interfaces/wasi-io-error.js"; +import { WasiIoStreams } from "./interfaces/wasi-io-streams.js"; +import { NomicFoundationSlangCst } from "./interfaces/nomic-foundation-slang-cst.js"; +import { NomicFoundationSlangAst } from "./interfaces/nomic-foundation-slang-ast.js"; +import { NomicFoundationSlangParser } from "./interfaces/nomic-foundation-slang-parser.js"; +export * as cst from "./interfaces/nomic-foundation-slang-cst.js"; +export * as ast from "./interfaces/nomic-foundation-slang-ast.js"; +export * as parser from "./interfaces/nomic-foundation-slang-parser.js"; diff --git a/crates/solidity/outputs/npm/package/wasm/index.mts b/crates/solidity/outputs/npm/package/wasm/index.mts new file mode 100644 index 0000000000..379dc59f54 --- /dev/null +++ b/crates/solidity/outputs/npm/package/wasm/index.mts @@ -0,0 +1 @@ +export * from "./generated/solidity_cargo_wasm.component.js"; diff --git a/crates/solidity/outputs/npm/tests/jest.config.ts b/crates/solidity/outputs/npm/tests/jest.config.ts index fe941944f1..ec6aa264d7 100644 --- a/crates/solidity/outputs/npm/tests/jest.config.ts +++ b/crates/solidity/outputs/npm/tests/jest.config.ts @@ -1,17 +1,11 @@ import type { Config } from "jest"; const config: Config = { - rootDir: __dirname, - testMatch: ["/src/doc-examples/**/*.ts"], + testMatch: ["/src/doc-examples/**/*.mts"], - moduleNameMapper: { - // __SLANG_NPM_PACKAGE_MAIN_OUTPUT_DIR__ (keep in sync) - "^@nomicfoundation/slang$": "/../package/target/npm/main", - "^@nomicfoundation/slang/(.*)?$": "/../package/target/npm/main/$1", - }, - - testEnvironment: "node", - preset: "ts-jest", + preset: "ts-jest/presets/default-esm", + resolver: "ts-jest-resolver", + moduleFileExtensions: ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx", "json", "node"], cacheDirectory: "/target/jest/cache", slowTestThreshold: 5, diff --git a/crates/solidity/outputs/npm/tests/package.json b/crates/solidity/outputs/npm/tests/package.json index b3b491927c..e7ec9f0404 100644 --- a/crates/solidity/outputs/npm/tests/package.json +++ b/crates/solidity/outputs/npm/tests/package.json @@ -1,10 +1,15 @@ { "name": "@slang-private/solidity-npm-tests", "private": true, + "type": "module", + "dependencies": { + "@nomicfoundation/slang": "file:../package" + }, "devDependencies": { "@types/jest": "29.5.13", "jest": "29.7.0", "ts-jest": "29.2.5", + "ts-jest-resolver": "2.0.1", "ts-node": "10.9.2" } } diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts new file mode 100644 index 0000000000..445b678207 --- /dev/null +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts @@ -0,0 +1,139 @@ +import { readRepoFile } from "../utils/files.mjs"; +import assert from "node:assert"; + +import { Parser } from "@nomicfoundation/slang/parser"; +import { assertIsNonterminalNode, NonterminalKind, Query, QueryMatchIterator } from "@nomicfoundation/slang/cst"; + +async function parseDocInputFile(relativePath: string) { + const source = await readRepoFile("documentation/public/user-guide/inputs", relativePath); + const parser = Parser.create("0.8.0"); + return parser.parse(NonterminalKind.SourceUnit, source); +} + +test("using queries", async () => { + { + const parseOutput = await parseDocInputFile("using-the-cursor.sol"); + // --8<-- [start:creating-a-query] + // Any `Cursor` can be used to create a query. + const cursor = parseOutput.createTreeCursor(); + + const query = Query.parse("[ContractDefinition]"); + const matches: QueryMatchIterator = cursor.query([query]); + // --8<-- [end:creating-a-query] + + matches; // Silence the unused warning + } + + { + const parseOutput = await parseDocInputFile("using-the-cursor.sol"); + const cursor = parseOutput.createTreeCursor(); + + // --8<-- [start:visiting-contracts] + const found = []; + + const query = Query.parse("@contract [ContractDefinition]"); + const matches = cursor.query([query]); + + for (const match of matches) { + const cursor = match.captures["contract"]![0]!; + + assertIsNonterminalNode(cursor.node); + found.push(cursor.node.unparse().trim()); + } + + assert.deepStrictEqual(found, ["contract Foo {}", "contract Bar {}", "contract Baz {}"]); + // --8<-- [end:visiting-contracts] + } + + { + const parseOutput = await parseDocInputFile("multiple-data-types.sol"); + const cursor = parseOutput.createTreeCursor(); + + // --8<-- [start:multiple-patterns] + const names = []; + + const structDefinition = Query.parse("[StructDefinition @name [Identifier]]"); + const enumDefinition = Query.parse("[EnumDefinition @name [Identifier]]"); + const matches = cursor.query([structDefinition, enumDefinition]); + + for (const match of matches) { + const index = match.queryNumber; + const cursor = match.captures["name"]![0]!; + + names.push([index, cursor.node.unparse()]); + } + + assert.deepStrictEqual(names, [ + [0, "Foo"], + [1, "Bar"], + [0, "Baz"], + [1, "Qux"], + ]); + // --8<-- [end:multiple-patterns] + } + + { + const parseOutput = await parseDocInputFile("typed-tuple.sol"); + const cursor = parseOutput.createTreeCursor(); + + // --8<-- [start:matching-on-label] + const names = []; + + const query = Query.parse("[TypedTupleMember @type type_name:[_]]"); + const matches = cursor.query([query]); + + for (const match of matches) { + const cursor = match.captures["type"]![0]!; + + names.push(cursor.node.unparse()); + } + + assert.deepStrictEqual(names, ["uint", " uint16", " uint64", " uint256"]); + // --8<-- [end:matching-on-label] + } + + { + // Matching on node's literal value + const parseOutput = await parseDocInputFile("typed-tuple.sol"); + const cursor = parseOutput.createTreeCursor(); + + // --8<-- [start:matching-on-literal-value] + const names = []; + + const query = Query.parse(`[ElementaryType @uint_keyword variant:["uint"]]`); + const matches = cursor.query([query]); + + for (const match of matches) { + const cursor = match.captures["uint_keyword"]![0]!; + + names.push(cursor.node.unparse()); + } + + assert.deepStrictEqual(names, ["uint"]); + // --8<-- [end:matching-on-literal-value] + } + + { + const parseOutput = await parseDocInputFile("tx-origin.sol"); + const cursor = parseOutput.createTreeCursor(); + + // --8<-- [start:tx-origin] + const query = Query.parse(` + @txorigin [MemberAccessExpression + [Expression @start ["tx"]] + ["origin"] + ]`); + + const matches = cursor.query([query]); + const found = []; + + for (const match of matches) { + const cursor = match.captures["txorigin"]![0]!; + + found.push([cursor.textOffset.utf8, cursor.node.unparse()]); + } + + assert.deepStrictEqual(found, [[375, "tx.origin"]]); + // --8<-- [end:tx-origin] + } +}); diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts deleted file mode 100644 index b105d53cc7..0000000000 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { repoPath } from "../utils/files"; -import path from "node:path"; -import assert from "node:assert"; -import fs from "node:fs/promises"; - -import { Parser } from "@nomicfoundation/slang/parser"; -import { NonterminalKind, NonterminalNode, Query, QueryMatchIterator, TerminalNode } from "@nomicfoundation/slang/cst"; - -async function parseDocInputFile(filePath: string) { - const inputPath = path.join(repoPath("documentation/public/user-guide/inputs"), filePath); - const source = await fs.readFile(inputPath, "utf8").then((source) => source.trim()); - const parser = new Parser("0.8.0"); - return parser.parse(NonterminalKind.SourceUnit, source); -} - -test("using queries", async () => { - { - const parse_output = await parseDocInputFile("using-the-cursor.sol"); - // --8<-- [start:creating-a-query] - - // Any `Cursor` can be used to create a query. - const cursor = parse_output.createTreeCursor(); - - const query = Query.parse("[ContractDefinition]"); - const matches: QueryMatchIterator = cursor.query([query]); - // --8<-- [end:creating-a-query] - matches; // Silence the unused warning - } - - { - const parseOutput = await parseDocInputFile("using-the-cursor.sol"); - const cursor = parseOutput.createTreeCursor(); - // --8<-- [start:visiting-contracts] - const found = []; - - const query = Query.parse("@contract [ContractDefinition]"); - const matches = cursor.query([query]); - - let match = null; - while ((match = matches.next())) { - const captures = match.captures; - const cursors = captures["contract"]; - - const cursor = cursors?.[0]?.node() as NonterminalNode; - - found.push(cursor.unparse().trim()); - } - - assert.deepStrictEqual(found, ["contract Foo {}", "contract Bar {}", "contract Baz {}"]); - // --8<-- [end:visiting-contracts] - } - - { - const parse_output = await parseDocInputFile("multiple-data-types.sol"); - const cursor = parse_output.createTreeCursor(); - // --8<-- [start:multiple-patterns] - const names = []; - - const struct_def = Query.parse("[StructDefinition @name [Identifier]]"); - const enum_def = Query.parse("[EnumDefinition @name [Identifier]]"); - const matches = cursor.query([struct_def, enum_def]); - - let match = null; - while ((match = matches.next())) { - const index = match.queryNumber; - const captures = match.captures; - const cursors = captures["name"]; - - const cursor = cursors?.[0]; - - names.push([index, (cursor?.node() as TerminalNode).text]); - } - - assert.deepStrictEqual(names, [ - [0, "Foo"], - [1, "Bar"], - [0, "Baz"], - [1, "Qux"], - ]); - // --8<-- [end:multiple-patterns] - } - - { - const parse_output = await parseDocInputFile("typed-tuple.sol"); - const cursor = parse_output.createTreeCursor(); - // --8<-- [start:matching-on-label] - - const names = []; - - const query = Query.parse("[TypedTupleMember @type type_name:[_]]"); - const matches = cursor.query([query]); - - let match = null; - while ((match = matches.next())) { - const captures = match.captures; - const cursors = captures["type"]; - - const cursor = cursors?.[0]; - - names.push((cursor?.node() as NonterminalNode).unparse()); - } - - assert.deepStrictEqual(names, ["uint", " uint16", " uint64", " uint256"]); - // --8<-- [end:matching-on-label] - } - - { - // Matching on node's literal value - const parse_output = await parseDocInputFile("typed-tuple.sol"); - const cursor = parse_output.createTreeCursor(); - // --8<-- [start:matching-on-literal-value] - - const names = []; - - const query = Query.parse(`[ElementaryType @uint_keyword variant:["uint"]]`); - const matches = cursor.query([query]); - - let match = null; - while ((match = matches.next())) { - const captures = match.captures; - const cursors = captures["uint_keyword"]; - - const cursor = cursors?.[0]; - - names.push((cursor?.node() as TerminalNode).text); - } - - assert.deepStrictEqual(names, ["uint"]); - // --8<-- [end:matching-on-literal-value] - } - - { - const parse_output = await parseDocInputFile("tx-origin.sol"); - const cursor = parse_output.createTreeCursor(); - // --8<-- [start:tx-origin] - const query = Query.parse(` - @txorigin [MemberAccessExpression - [Expression @start ["tx"]] - ["origin"] - ]`); - const matches = cursor.query([query]); - - const found = []; - - let match = null; - while ((match = matches.next())) { - const captures = match.captures; - const cursors = captures["txorigin"]; - - const cursor = cursors?.[0]; - - found.push([cursor?.textOffset.utf8, (cursor?.node() as NonterminalNode).unparse()]); - } - - assert.deepStrictEqual(found, [[375, "tx.origin"]]); - // --8<-- [end:tx-origin] - } -}); diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts similarity index 63% rename from crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts rename to crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts index ef67caaafc..7cf8e91008 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts @@ -1,32 +1,30 @@ -import { repoPath } from "../utils/files"; -import fs from "node:fs/promises"; +import { readRepoFile } from "../utils/files.mjs"; // --8<-- [start:imports] import assert from "node:assert"; import { Parser } from "@nomicfoundation/slang/parser"; -import { NonterminalKind, NonterminalNode } from "@nomicfoundation/slang/cst"; +import { NonterminalKind } from "@nomicfoundation/slang/cst"; import { FunctionDefinition } from "@nomicfoundation/slang/ast"; // --8<-- [end:imports] test("using the ast", async () => { - const inputPath = repoPath("documentation/public/user-guide/inputs/using-the-ast.sol"); - const source = (await fs.readFile(inputPath, "utf8")).trim(); + const source = await readRepoFile("documentation/public/user-guide/inputs/using-the-ast.sol"); // --8<-- [start:parse-input] - const parser = new Parser("0.8.0"); + const parser = Parser.create("0.8.0"); const parseOutput = parser.parse(NonterminalKind.FunctionDefinition, source); // --8<-- [end:parse-input] // --8<-- [start:create-node] - const $function = new FunctionDefinition(parseOutput.tree() as NonterminalNode); + const $function = new FunctionDefinition(parseOutput.tree.asNonterminalNode()!); - assert.equal($function.name.variant.text, "add"); + assert.equal($function.name.variant.unparse(), "add"); // --8<-- [end:create-node] // --8<-- [start:list-parameters] const parameters = $function.parameters.parameters.items.map((parameter) => { - return parameter.name?.text; + return parameter.name!.unparse(); }); assert.deepEqual(parameters, ["a", "b"]); diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts similarity index 71% rename from crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts rename to crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts index 88fe0297c8..ea98c8233b 100644 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts @@ -1,18 +1,16 @@ -import { repoPath } from "../utils/files"; -import fs from "node:fs/promises"; +import { readRepoFile } from "../utils/files.mjs"; // --8<-- [start:imports] import assert from "node:assert"; import { Parser } from "@nomicfoundation/slang/parser"; -import { NonterminalKind, NonterminalNode, TerminalKind, TerminalNode } from "@nomicfoundation/slang/cst"; +import { assertIsTerminalNode, NonterminalKind, TerminalKind } from "@nomicfoundation/slang/cst"; // --8<-- [end:imports] test("using the cursor", async () => { - const inputPath = repoPath("documentation/public/user-guide/inputs/using-the-cursor.sol"); - const source = (await fs.readFile(inputPath, "utf8")).trim(); + const source = await readRepoFile("documentation/public/user-guide/inputs/using-the-cursor.sol"); // --8<-- [start:parse-input] - const parser = new Parser("0.8.0"); + const parser = Parser.create("0.8.0"); const parseOutput = parser.parse(NonterminalKind.SourceUnit, source); // --8<-- [end:parse-input] @@ -27,9 +25,8 @@ test("using the cursor", async () => { assert(cursor.goToFirstChild()); assert(cursor.goToNextTerminalWithKind(TerminalKind.Identifier)); - const terminalNode = cursor.node(); - assert(terminalNode instanceof TerminalNode); - contracts.push(terminalNode.text); + assertIsTerminalNode(cursor.node); + contracts.push(cursor.node.unparse()); assert(cursor.goToParent()); } @@ -48,9 +45,8 @@ test("using the cursor", async () => { const childCursor = cursor.spawn(); assert(childCursor.goToNextTerminalWithKind(TerminalKind.Identifier)); - const terminalNode = childCursor.node(); - assert(terminalNode instanceof TerminalNode); - contracts.push(terminalNode.text); + assertIsTerminalNode(childCursor.node); + contracts.push(childCursor.node.unparse()); } assert.deepStrictEqual(contracts, ["Foo", "Bar", "Baz"]); @@ -66,8 +62,7 @@ test("using the cursor", async () => { while (cursor.goToNextNonterminalWithKind(NonterminalKind.ContractDefinition)) { const range = cursor.textRange; - const contractNode = cursor.node(); - assert(contractNode instanceof NonterminalNode); + const contractNode = cursor.node; contracts.push([ range.start.line, diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts new file mode 100644 index 0000000000..c89f7dbe3d --- /dev/null +++ b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts @@ -0,0 +1,55 @@ +import { readRepoFile } from "../utils/files.mjs"; + +// --8<-- [start:imports] +import assert from "node:assert"; +import { Parser } from "@nomicfoundation/slang/parser"; +import { + assertIsNonterminalNode, + assertIsTerminalNode, + NonterminalKind, + TerminalKind, +} from "@nomicfoundation/slang/cst"; +// --8<-- [end:imports] + +test("using the parser", async () => { + const source = await readRepoFile("documentation/public/user-guide/inputs/using-the-parser.sol"); + + // --8<-- [start:parse-input] + const parser = Parser.create("0.8.0"); + + const parseOutput = parser.parse(NonterminalKind.ContractDefinition, source); + // --8<-- [end:parse-input] + + // --8<-- [start:print-errors] + for (const error of parseOutput.errors) { + console.error(`Error at byte offset ${error.textRange.start.utf8}: ${error.message}`); + } + // --8<-- [end:print-errors] + + // --8<-- [start:assert-is-valid] + assert(parseOutput.isValid()); + // --8<-- [end:assert-is-valid] + + // --8<-- [start:inspect-tree] + const contract = parseOutput.tree; + assertIsNonterminalNode(contract, NonterminalKind.ContractDefinition); + + const contractChildren = contract.children; + assert.equal(contractChildren.length, 7); + + const [contractKeyword, firstSpace, contractName, secondSpace, openBrace, members, closeBrace] = contractChildren; + + assertIsTerminalNode(contractKeyword!.node, TerminalKind.ContractKeyword, "contract"); + assertIsTerminalNode(firstSpace!.node, TerminalKind.Whitespace, " "); + assertIsTerminalNode(contractName!.node, TerminalKind.Identifier, "Foo"); + assertIsTerminalNode(secondSpace!.node, TerminalKind.Whitespace, " "); + assertIsTerminalNode(openBrace!.node, TerminalKind.OpenBrace, "{"); + assertIsNonterminalNode(members!.node, NonterminalKind.ContractMembers); + assertIsTerminalNode(closeBrace!.node, TerminalKind.CloseBrace, "}"); + // --8<-- [end:inspect-tree] + + // --8<-- [start:unparse-node] + const contractSource = contract.unparse(); + assert.equal(contractSource, "contract Foo {}"); + // --8<-- [end:unparse-node] +}); diff --git a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts b/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts deleted file mode 100644 index 91ef79675b..0000000000 --- a/crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { repoPath } from "../utils/files"; -import fs from "node:fs/promises"; - -// --8<-- [start:imports] -import assert from "node:assert"; -import { Parser } from "@nomicfoundation/slang/parser"; -import { NonterminalKind, NonterminalNode, TerminalKind } from "@nomicfoundation/slang/cst"; -// --8<-- [end:imports] - -test("using the parser", async () => { - const inputPath = repoPath("documentation/public/user-guide/inputs/using-the-parser.sol"); - const source = (await fs.readFile(inputPath, "utf8")).trim(); - - // --8<-- [start:parse-input] - const parser = new Parser("0.8.0"); - - const parseOutput = parser.parse(NonterminalKind.ContractDefinition, source); - // --8<-- [end:parse-input] - - // --8<-- [start:print-errors] - for (const error of parseOutput.errors()) { - console.error(`Error at byte offset ${error.textRange().start.utf8}: ${error.message()}`); - } - // --8<-- [end:print-errors] - - // --8<-- [start:assert-is-valid] - assert(parseOutput.isValid); - // --8<-- [end:assert-is-valid] - - // --8<-- [start:inspect-tree] - const contract = parseOutput.tree(); - assert(contract instanceof NonterminalNode); - assert.equal(contract.kind, NonterminalKind.ContractDefinition); - - const contractChildren = contract.children(); - assert.equal(contractChildren.length, 7); - - const [contractKeyword, firstSpace, contractName, secondSpace, openBrace, members, closeBrace] = contractChildren; - - assert.equal(contractKeyword?.kind, TerminalKind.ContractKeyword); - assert.equal(firstSpace?.kind, TerminalKind.Whitespace); - assert.equal(contractName?.kind, TerminalKind.Identifier); - assert.equal(secondSpace?.kind, TerminalKind.Whitespace); - assert.equal(openBrace?.kind, TerminalKind.OpenBrace); - assert.equal(members?.kind, NonterminalKind.ContractMembers); - assert.equal(closeBrace?.kind, TerminalKind.CloseBrace); - // --8<-- [end:inspect-tree] - - // --8<-- [start:unparse-node] - const contractSource = contract.unparse(); - assert.equal(contractSource, "contract Foo {}"); - // --8<-- [end:unparse-node] -}); diff --git a/crates/solidity/outputs/npm/tests/src/utils/files.mts b/crates/solidity/outputs/npm/tests/src/utils/files.mts new file mode 100644 index 0000000000..eea2f810c7 --- /dev/null +++ b/crates/solidity/outputs/npm/tests/src/utils/files.mts @@ -0,0 +1,13 @@ +import assert from "node:assert"; +import fs from "node:fs/promises"; +import path from "node:path"; + +export async function readRepoFile(...relativePaths: string[]): Promise { + const repoRoot = process.env["REPO_ROOT"]; + assert(repoRoot); + + const absolutePath = path.join(repoRoot, ...relativePaths); + const source = await fs.readFile(absolutePath, "utf8"); + + return source.trim(); +} diff --git a/crates/solidity/outputs/npm/tests/src/utils/files.ts b/crates/solidity/outputs/npm/tests/src/utils/files.ts deleted file mode 100644 index 3d356a1bcc..0000000000 --- a/crates/solidity/outputs/npm/tests/src/utils/files.ts +++ /dev/null @@ -1,9 +0,0 @@ -import assert from "node:assert"; -import path from "node:path"; - -export function repoPath(relativePath: string): string { - const repoRoot = process.env["REPO_ROOT"]; - assert(repoRoot); - - return path.join(repoRoot, relativePath); -} diff --git a/crates/solidity/outputs/npm/tests/tsconfig.json b/crates/solidity/outputs/npm/tests/tsconfig.json index 487f99514a..7b4d9a1ad1 100644 --- a/crates/solidity/outputs/npm/tests/tsconfig.json +++ b/crates/solidity/outputs/npm/tests/tsconfig.json @@ -1,16 +1,9 @@ { "extends": "../../../../../tsconfig.json", - "include": ["./src/**/*.ts", "./jest.config.ts"], + "include": ["./**/*"], "compilerOptions": { - /* Modules */ - "paths": { - // __SLANG_NPM_PACKAGE_MAIN_OUTPUT_DIR__ (keep in sync) - "@nomicfoundation/slang": ["../package/target/npm/main"], - "@nomicfoundation/slang/*": ["../package/target/npm/main/*"] - }, - /* Projects */ "composite": true, "incremental": true, diff --git a/crates/solidity/outputs/spec/generated/grammar.ebnf b/crates/solidity/outputs/spec/generated/grammar.ebnf index e9af140a9b..b98b5f5db4 100644 --- a/crates/solidity/outputs/spec/generated/grammar.ebnf +++ b/crates/solidity/outputs/spec/generated/grammar.ebnf @@ -34,11 +34,11 @@ PragmaDirective = (* pragma_keyword: *) PRAGMA_KEYWORD (* pragma: *) Pragma (* semicolon: *) SEMICOLON; -Pragma = (* variant: *) ABICoderPragma +Pragma = (* variant: *) AbicoderPragma | (* variant: *) ExperimentalPragma | (* variant: *) VersionPragma; -ABICoderPragma = (* abicoder_keyword: *) ABICODER_KEYWORD +AbicoderPragma = (* abicoder_keyword: *) ABICODER_KEYWORD (* version: *) IDENTIFIER; ExperimentalPragma = (* experimental_keyword: *) EXPERIMENTAL_KEYWORD diff --git a/crates/solidity/outputs/spec/generated/public/01-file-structure/03-pragma-directives.md b/crates/solidity/outputs/spec/generated/public/01-file-structure/03-pragma-directives.md index 935016d5c0..c90ee12f58 100644 --- a/crates/solidity/outputs/spec/generated/public/01-file-structure/03-pragma-directives.md +++ b/crates/solidity/outputs/spec/generated/public/01-file-structure/03-pragma-directives.md @@ -14,13 +14,13 @@ ``` -
Pragma = (* variant: *) ABICoderPragma
| (* variant: *) ExperimentalPragma
| (* variant: *) VersionPragma;
+
Pragma = (* variant: *) AbicoderPragma
| (* variant: *) ExperimentalPragma
| (* variant: *) VersionPragma;
-```{ .ebnf #ABICoderPragma } +```{ .ebnf #AbicoderPragma } ``` -
ABICoderPragma = (* abicoder_keyword: *) ABICODER_KEYWORD
(* version: *) IDENTIFIER;
+
AbicoderPragma = (* abicoder_keyword: *) ABICODER_KEYWORD
(* version: *) IDENTIFIER;
```{ .ebnf #ExperimentalPragma } diff --git a/crates/solidity/testing/perf/benches/iai/tests/parser.rs b/crates/solidity/testing/perf/benches/iai/tests/parser.rs index b17facf6db..0a34f247e6 100644 --- a/crates/solidity/testing/perf/benches/iai/tests/parser.rs +++ b/crates/solidity/testing/perf/benches/iai/tests/parser.rs @@ -19,7 +19,7 @@ pub fn setup() -> Vec { } pub fn run(files: Vec) -> Vec { - let parser = Parser::new(SOLC_VERSION).unwrap(); + let parser = Parser::create(SOLC_VERSION).unwrap(); let mut results = vec![]; diff --git a/crates/solidity/testing/sanctuary/Cargo.toml b/crates/solidity/testing/sanctuary/Cargo.toml index 499af91746..a65bec5bef 100644 --- a/crates/solidity/testing/sanctuary/Cargo.toml +++ b/crates/solidity/testing/sanctuary/Cargo.toml @@ -17,7 +17,7 @@ rayon = { workspace = true } semver = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -slang_solidity = { workspace = true, features = ["__private_testing_utils"] } +slang_solidity = { workspace = true, features = ["__private_ariadne_errors"] } strum_macros = { workspace = true } url = { workspace = true } diff --git a/crates/solidity/testing/sanctuary/src/tests.rs b/crates/solidity/testing/sanctuary/src/tests.rs index 79fdea3ccc..054ef801be 100644 --- a/crates/solidity/testing/sanctuary/src/tests.rs +++ b/crates/solidity/testing/sanctuary/src/tests.rs @@ -98,7 +98,7 @@ pub fn run_test(file: &SourceFile, events: &Events) -> Result<()> { // https://github.com/tintinweb/smart-contract-sanctuary/issues/32 .replace("'", "\""); - let parser = Parser::new(version.clone())?; + let parser = Parser::create(version.clone())?; let output = parser.parse(NonterminalKind::SourceUnit, &source); if output.is_valid() { diff --git a/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml b/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml index b8b86b92d6..732a475d06 100644 --- a/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml +++ b/crates/solidity/testing/snapshots/cst_output/PragmaDirective/abi_coder/generated/0.4.11-success.yml @@ -8,7 +8,7 @@ Errors: [] Tree: - (PragmaDirective): # "pragma abicoder foo;" (0..20) - (pragma_keyword꞉ PragmaKeyword): "pragma" # (0..6) - - (pragma꞉ Pragma) ► (variant꞉ ABICoderPragma): # " abicoder foo" (6..19) + - (pragma꞉ Pragma) ► (variant꞉ AbicoderPragma): # " abicoder foo" (6..19) - (leading_trivia꞉ Whitespace): " " # (6..7) - (abicoder_keyword꞉ AbicoderKeyword): "abicoder" # (7..15) - (leading_trivia꞉ Whitespace): " " # (15..16) diff --git a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml b/crates/testlang/outputs/cargo/crate/Cargo.toml similarity index 68% rename from crates/testlang/outputs/cargo/slang_testlang/Cargo.toml rename to crates/testlang/outputs/cargo/crate/Cargo.toml index 54fcb2aa7c..eeb4213383 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/Cargo.toml +++ b/crates/testlang/outputs/cargo/crate/Cargo.toml @@ -10,9 +10,8 @@ name = "slang_testlang" [features] default = [] __experimental_bindings_api = ["dep:metaslang_bindings"] -__private_cli_execution = ["dep:ariadne", "dep:clap", "dep:serde_json"] -__private_testing_utils = ["dep:ariadne"] -__private_wit_bindings = ["dep:paste", "dep:wit-bindgen"] +__private_ariadne_errors = ["dep:ariadne"] +__private_testing_utils = [] [build-dependencies] anyhow = { workspace = true } @@ -22,17 +21,13 @@ testlang_language = { workspace = true } [dependencies] ariadne = { workspace = true, optional = true } -clap = { workspace = true, optional = true } metaslang_bindings = { workspace = true, optional = true } metaslang_cst = { workspace = true } -paste = { workspace = true, optional = 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/testlang/outputs/cargo/slang_testlang/build.rs b/crates/testlang/outputs/cargo/crate/build.rs similarity index 53% rename from crates/testlang/outputs/cargo/slang_testlang/build.rs rename to crates/testlang/outputs/cargo/crate/build.rs index 7b2f00b850..00212d7515 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/build.rs +++ b/crates/testlang/outputs/cargo/crate/build.rs @@ -1,12 +1,15 @@ use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; +use codegen_runtime_generator::RuntimeGenerator; use infra_utils::cargo::CargoWorkspace; use testlang_language::TestlangDefinition; fn main() -> Result<()> { let language = TestlangDefinition::create(); + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_cargo_crate")?.join("src/runtime"); + let output_dir = CargoWorkspace::locate_source_crate("slang_testlang")?.join("src/generated"); - OutputLanguage::Cargo.generate_runtime(&language, &output_dir) + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/generated/binding_rules.rs b/crates/testlang/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/generated/binding_rules.rs rename to crates/testlang/outputs/cargo/crate/src/generated/bindings/generated/binding_rules.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/bindings/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs diff --git a/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs new file mode 100644 index 0000000000..21fda384c9 --- /dev/null +++ b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/edge_label.rs @@ -0,0 +1,43 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, +)] +#[strum(serialize_all = "snake_case")] +#[derive(Clone, Copy)] +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 crate::cst::EdgeLabelExtensions for EdgeLabel {} diff --git a/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs new file mode 100644 index 0000000000..3992c49008 --- /dev/null +++ b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/lexical_context.rs @@ -0,0 +1,34 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +/// The lexical context of the scanner. + +#[repr(u8)] +#[derive(strum_macros::FromRepr, Clone, Copy)] +pub(crate) enum LexicalContext { + Default, + Tree, +} + +/// Marker trait for type-level [`LexicalContext`] variants. +pub(crate) trait IsLexicalContext { + /// Returns a run-time [`LexicalContext`] value. + fn value() -> LexicalContext; +} + +#[allow(non_snake_case)] +pub(crate) mod LexicalContextType { + pub struct Default; + + impl super::IsLexicalContext for Default { + fn value() -> super::LexicalContext { + super::LexicalContext::Default + } + } + pub struct Tree; + + impl super::IsLexicalContext for Tree { + fn value() -> super::LexicalContext { + super::LexicalContext::Tree + } + } +} diff --git a/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs new file mode 100644 index 0000000000..48c37113f0 --- /dev/null +++ b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/nonterminal_kind.rs @@ -0,0 +1,35 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +pub enum NonterminalKind { + AdditionExpression, + Expression, + Literal, + MemberAccessExpression, + NegationExpression, + SeparatedIdentifiers, + SourceUnit, + SourceUnitMember, + SourceUnitMembers, + Tree, + TreeNode, + TreeNodeChild, + TreeNodeChildren, +} + +impl crate::cst::NonterminalKindExtensions for NonterminalKind {} diff --git a/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs new file mode 100644 index 0000000000..6e21121cbf --- /dev/null +++ b/crates/testlang/outputs/cargo/crate/src/generated/cst/generated/terminal_kind.rs @@ -0,0 +1,52 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[repr(u8)] +#[derive( + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + serde::Serialize, + strum_macros::AsRefStr, + strum_macros::Display, + strum_macros::EnumString, + strum_macros::IntoStaticStr, + Clone, + Copy, +)] +#[allow(clippy::upper_case_acronyms)] +pub enum TerminalKind { + // Built-in: + UNRECOGNIZED, + MISSING, + + // Generated: + Bang, + CloseBracket, + DelimitedIdentifier, + EndOfLine, + Identifier, + MultiLineComment, + OpenBracket, + Period, + Plus, + Semicolon, + SingleLineComment, + StringLiteral, + TreeKeyword, + Whitespace, +} + +impl crate::cst::TerminalKindExtensions for TerminalKind { + fn is_trivia(&self) -> bool { + matches!(self, |Self::EndOfLine| Self::MultiLineComment + | Self::SingleLineComment + | Self::Whitespace) + } + + fn is_valid(&self) -> bool { + !matches!(self, Self::UNRECOGNIZED | Self::MISSING) + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/cst/mod.rs similarity index 80% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/cst/mod.rs index ccbf409bc6..9f169288b9 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/cst/mod.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/cst/mod.rs @@ -1,13 +1,21 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -#[path = "generated/kinds.rs"] -mod kinds; +#[path = "generated/edge_label.rs"] +mod edge_label; +#[path = "generated/lexical_context.rs"] +mod lexical_context; +#[path = "generated/nonterminal_kind.rs"] +mod nonterminal_kind; +#[path = "generated/terminal_kind.rs"] +mod terminal_kind; -pub use kinds::{EdgeLabel, NonterminalKind, TerminalKind}; -pub(crate) use kinds::{IsLexicalContext, LexicalContext, LexicalContextType}; +pub use edge_label::EdgeLabel; +pub(crate) use lexical_context::{IsLexicalContext, LexicalContext, LexicalContextType}; pub use metaslang_cst::kinds::{ EdgeLabelExtensions, NonterminalKindExtensions, TerminalKindExtensions, }; +pub use nonterminal_kind::NonterminalKind; +pub use terminal_kind::TerminalKind; // These derives are because default #[derive(...)] on a generic type implements only the trait // with default bounds also implied for the generic types as well, i.e. @@ -38,7 +46,8 @@ pub type Cursor = metaslang_cst::cursor::Cursor; pub type CursorWithEdges = metaslang_cst::cursor::CursorWithEdges; pub type Query = metaslang_cst::query::Query; +pub use metaslang_cst::query::QueryError; pub type QueryMatch = metaslang_cst::query::QueryMatch; pub type QueryMatchIterator = metaslang_cst::query::QueryMatchIterator; -pub use metaslang_cst::query::QueryError; + pub use metaslang_cst::text_index::{TextIndex, TextRange, TextRangeExtensions}; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/diagnostic/mod.rs similarity index 96% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/diagnostic/mod.rs index 3e06aaaf77..06882bea3f 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/diagnostic/mod.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/diagnostic/mod.rs @@ -24,10 +24,7 @@ pub trait Diagnostic { fn message(&self) -> String; } -#[cfg(any( - feature = "__private_cli_execution", - feature = "__private_testing_utils" -))] +#[cfg(feature = "__private_ariadne_errors")] pub fn render(error: &D, source_id: &str, source: &str, with_color: bool) -> String { use ariadne::{Color, Config, Label, Report, ReportKind, Source}; diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/mod.rs similarity index 52% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/mod.rs index 80a635d4af..4b9d48d9f9 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/mod.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/mod.rs @@ -1,17 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +#[cfg(feature = "__experimental_bindings_api")] +pub mod bindings; pub mod cst; pub mod diagnostic; pub mod parser; - -#[cfg(feature = "__experimental_bindings_api")] -pub mod bindings; - -#[cfg(feature = "__private_cli_execution")] -pub mod cli; - -#[cfg(feature = "__private_napi_interfaces")] -pub mod napi_interface; - -#[cfg(feature = "__private_wit_bindings")] -pub mod wit; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/generated/parser.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/generated/parser.rs similarity index 93% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/generated/parser.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/generated/parser.rs index ab7fd20c62..9526734434 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/generated/parser.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/parser/generated/parser.rs @@ -10,16 +10,12 @@ unused_imports )] -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; use semver::Version; use crate::cst; use crate::cst::{ EdgeLabel, IsLexicalContext, LexicalContext, LexicalContextType, NonterminalKind, TerminalKind, }; -#[cfg(feature = "__private_napi_interfaces")] -use crate::napi_interface::parser::ParseOutput as NAPIParseOutput; use crate::parser::lexer::{KeywordScan, Lexer, ScannedTerminal}; use crate::parser::parser_support::{ ChoiceHelper, OneOrMoreHelper, OptionalHelper, ParserContext, ParserFunction, ParserResult, @@ -33,28 +29,16 @@ use crate::parser::scanner_macros::{ use crate::parser::ParseOutput; #[derive(Debug)] -#[cfg_attr(feature = "__private_napi_interfaces", napi(namespace = "parser"))] pub struct Parser { #[allow(dead_code)] pub(crate) version_is_at_least_1_0_0: bool, - pub(crate) version: Version, + pub version: Version, } #[derive(thiserror::Error, Debug)] pub enum ParserInitializationError { #[error("Unsupported language version '{0}'.")] UnsupportedLanguageVersion(Version), - - #[cfg(feature = "__private_napi_interfaces")] - #[error("Invalid semantic version '{0}'.")] - InvalidSemanticVersion(String), -} - -#[cfg(feature = "__private_napi_interfaces")] -impl From for napi::Error { - fn from(value: ParserInitializationError) -> Self { - napi::Error::from_reason(value.to_string()) - } } impl Parser { @@ -67,7 +51,7 @@ impl Parser { pub const ROOT_KIND: NonterminalKind = NonterminalKind::SourceUnit; - pub fn new(version: Version) -> std::result::Result { + pub fn create(version: Version) -> std::result::Result { if Self::SUPPORTED_VERSIONS.binary_search(&version).is_ok() { Ok(Self { version_is_at_least_1_0_0: Version::new(1, 0, 0) <= version, @@ -828,47 +812,3 @@ impl Lexer for Parser { } } } - -#[cfg(feature = "__private_napi_interfaces")] -// NAPI-exposed functions have to accept owned values. -#[allow(clippy::needless_pass_by_value)] -#[napi(namespace = "parser")] -impl Parser { - #[napi(constructor, catch_unwind)] - pub fn new_napi(version: String) -> std::result::Result { - let version = Version::parse(&version) - .map_err(|_| ParserInitializationError::InvalidSemanticVersion(version))?; - Self::new(version).map_err(|e| e.into()) - } - - #[napi(getter, js_name = "version", catch_unwind)] - pub fn version_napi(&self) -> String { - self.version.to_string() - } - - #[napi(js_name = "supportedVersions", catch_unwind)] - pub fn supported_versions_napi() -> Vec { - return Self::SUPPORTED_VERSIONS - .iter() - .map(|v| v.to_string()) - .collect(); - } - - #[napi( - js_name = "rootKind", - ts_return_type = "cst.NonterminalKind", - catch_unwind - )] - pub fn root_kind_napi() -> NonterminalKind { - Self::ROOT_KIND - } - - #[napi(js_name = "parse", ts_return_type = "parser.ParseOutput", catch_unwind)] - pub fn parse_napi( - &self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - input: String, - ) -> NAPIParseOutput { - self.parse(kind, input.as_str()).into() - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/lexer/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/lexer/mod.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/lexer/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/lexer/mod.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/mod.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/mod.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parse_error.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parse_error.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parse_error.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parse_error.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parse_output.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parse_output.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parse_output.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parse_output.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/choice_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/choice_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/choice_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/choice_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/context.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/context.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/context.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/context.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/mod.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/mod.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/optional_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/optional_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/optional_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/optional_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/parser_function.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/parser_function.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/parser_function.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/parser_function.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/parser_result.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/parser_result.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/parser_result.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/parser_result.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/precedence_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/precedence_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/precedence_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/precedence_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/recovery.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/recovery.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/recovery.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/recovery.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/repetition_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/repetition_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/repetition_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/repetition_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/separated_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/separated_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/separated_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/separated_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/sequence_helper.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/sequence_helper.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/parser_support/sequence_helper.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/parser_support/sequence_helper.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/scanner_macros/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/parser/scanner_macros/mod.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/parser/scanner_macros/mod.rs rename to crates/testlang/outputs/cargo/crate/src/generated/parser/scanner_macros/mod.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/lib.rs b/crates/testlang/outputs/cargo/crate/src/lib.rs similarity index 100% rename from crates/testlang/outputs/cargo/slang_testlang/src/lib.rs rename to crates/testlang/outputs/cargo/crate/src/lib.rs diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/parse.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/parse.rs deleted file mode 100644 index 8c5a51610d..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/parse.rs +++ /dev/null @@ -1,60 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use std::fs; -use std::path::PathBuf; - -use semver::Version; - -use crate::diagnostic; -use crate::parser::Parser; - -#[derive(clap::Parser, Debug)] -pub struct ParseCommand { - /// File path to the source file to parse - file_path: PathBuf, - - /// The language version to use for parsing - #[arg(short, long)] - version: Version, - - /// Print the concrete syntax tree as JSON - #[clap(long)] - json: bool, -} - -impl ParseCommand { - pub fn execute(self) { - let Self { - file_path, - version, - json, - } = self; - - let file_path = file_path - .canonicalize() - .unwrap_or_else(|_| panic!("File not found: {file_path:?}")); - - let input = fs::read_to_string(&file_path).unwrap(); - let parser = Parser::new(version).unwrap(); - let parse_output = parser.parse(Parser::ROOT_KIND, &input); - - if !parse_output.is_valid() { - const COLOR: bool = true; - - let report = parse_output - .errors() - .iter() - .map(|error| diagnostic::render(error, file_path.to_str().unwrap(), &input, COLOR)) - .collect::>() - .join("\n"); - - panic!("Parse failed:\n{report}"); - } - - if json { - let json = serde_json::to_string_pretty(&parse_output.tree()).unwrap(); - - println!("{json}"); - } - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs deleted file mode 100644 index 4d7994dd92..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -mod commands; - -use clap::{Parser, Subcommand}; - -use crate::cli::commands::parse::ParseCommand; - -#[derive(Parser, Debug)] -#[command(next_line_help = true)] -#[command(author, about)] -struct Cli { - #[command(subcommand)] - command: Commands, -} - -#[derive(Subcommand, Debug)] -enum Commands { - /// Parses a source file, and outputs any syntax errors, or a JSON concrete syntax tree - Parse(ParseCommand), -} - -pub fn execute() { - match Cli::parse().command { - Commands::Parse(command) => command.execute(), - }; -} - -#[test] -fn verify_clap_cli() { - // Catches problems earlier in the development cycle: - ::command().debug_assert(); -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/generated/kinds.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/generated/kinds.rs deleted file mode 100644 index bd0077186b..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cst/generated/kinds.rs +++ /dev/null @@ -1,168 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#[cfg(feature = "__private_napi_interfaces")] -use napi_derive::napi; - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -pub enum NonterminalKind { - AdditionExpression, - Expression, - Literal, - MemberAccessExpression, - NegationExpression, - SeparatedIdentifiers, - SourceUnit, - SourceUnitMember, - SourceUnitMembers, - Tree, - TreeNode, - TreeNodeChild, - TreeNodeChildren, -} - -impl crate::cst::NonterminalKindExtensions for NonterminalKind {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[strum(serialize_all = "snake_case")] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -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 crate::cst::EdgeLabelExtensions for EdgeLabel {} - -// This needs to stay in sync with the wit-bindgen output -#[repr(u8)] -#[derive( - Debug, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - serde::Serialize, - strum_macros::AsRefStr, - strum_macros::Display, - strum_macros::EnumString, - strum_macros::IntoStaticStr, -)] -#[cfg_attr(feature = "__private_napi_interfaces", /* derives `Clone` and `Copy` */ napi(string_enum, namespace = "cst"))] -#[cfg_attr(not(feature = "__private_napi_interfaces"), derive(Clone, Copy))] -#[allow(clippy::upper_case_acronyms)] -pub enum TerminalKind { - // Built-in: - UNRECOGNIZED, - MISSING, - - // Generated: - Bang, - CloseBracket, - DelimitedIdentifier, - EndOfLine, - Identifier, - MultiLineComment, - OpenBracket, - Period, - Plus, - Semicolon, - SingleLineComment, - StringLiteral, - TreeKeyword, - Whitespace, -} - -impl crate::cst::TerminalKindExtensions for TerminalKind { - fn is_trivia(&self) -> bool { - matches!(self, |Self::EndOfLine| Self::MultiLineComment - | Self::SingleLineComment - | Self::Whitespace) - } - - fn is_valid(&self) -> bool { - !matches!(self, Self::UNRECOGNIZED | Self::MISSING) - } -} - -/// 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, - Tree, -} - -/// Marker trait for type-level [`LexicalContext`] variants. -pub(crate) trait IsLexicalContext { - /// Returns a run-time [`LexicalContext`] value. - fn value() -> LexicalContext; -} - -#[allow(non_snake_case)] -pub(crate) mod LexicalContextType { - pub struct Default; - - impl super::IsLexicalContext for Default { - fn value() -> super::LexicalContext { - super::LexicalContext::Default - } - } - pub struct Tree; - - impl super::IsLexicalContext for Tree { - fn value() -> super::LexicalContext { - super::LexicalContext::Tree - } - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs deleted file mode 100644 index aa8584a3c5..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs +++ /dev/null @@ -1,482 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// NAPI-exposed functions have to accept owned values -#![allow(clippy::needless_pass_by_value)] -// The functions are meant to be definitions for export, so they're not really used -#![allow(clippy::return_self_not_must_use)] - -use std::collections::HashMap; -use std::rc::Rc; - -use napi::bindgen_prelude::ClassInstance; -use napi::{Either, Env}; -use napi_derive::napi; - -use crate::napi_interface::{ - EdgeLabel, NonterminalKind, RustCursor, RustNode, RustNonterminalNode, RustQuery, - RustQueryMatch, RustQueryMatchIterator, RustTerminalNode, RustTextIndex, RustTextRange, - TerminalKind, -}; - -#[napi(namespace = "cst", string_enum)] -pub enum NodeType { - Nonterminal, - Terminal, -} - -pub trait NAPINodeExtensions { - fn into_js_either_node(self) -> Either; -} - -impl NAPINodeExtensions for RustNode { - /// Converts the node into `napi` wrapper for `NonterminalNode | TerminalNode` JS object. - fn into_js_either_node(self) -> Either { - match self { - RustNode::Nonterminal(nonterminal) => Either::A(NonterminalNode(nonterminal)), - RustNode::Terminal(terminal) => Either::B(TerminalNode(terminal)), - } - } -} - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct NonterminalNode(pub(crate) Rc); - -#[derive(Debug)] -#[napi(namespace = "cst")] -pub struct TerminalNode(pub(crate) Rc); - -#[napi(namespace = "cst")] -impl NonterminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Nonterminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Nonterminal - } - - #[napi(getter, ts_return_type = "cst.NonterminalKind", catch_unwind)] - pub fn kind(&self) -> NonterminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - self.0.text_len.into() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn children(&self) -> Vec> { - self.0 - .children - .iter() - .map(|child| child.node.clone().into_js_either_node()) - .collect() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Nonterminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(catch_unwind)] - pub fn unparse(&self) -> String { - Rc::clone(&self.0).unparse() - } - - // Expose the children as a hidden (non-enumerable, don't generate type definition) - // property that's eagerly evaluated (getter) for an inspected parent object in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__children", // Needed; otherwise, the property name would shadow `children`. - skip_typescript, - catch_unwind - )] - pub fn __children(&self) -> Vec> { - Self::children(self) - } - - // Similarly, expose the eagerly evaluated unparsed text in the debugger context. - #[napi( - enumerable = false, - configurable = false, - writable = false, - getter, - js_name = "__text", - skip_typescript, - catch_unwind - )] - pub fn __text(&self) -> String { - self.unparse() - } -} - -#[napi(namespace = "cst")] -impl TerminalNode { - #[napi( - getter, - js_name = "type", - ts_return_type = "cst.NodeType.Terminal", - catch_unwind - )] - pub fn tipe(&self) -> NodeType { - NodeType::Terminal - } - - #[napi(getter, ts_return_type = "cst.TerminalKind", catch_unwind)] - pub fn kind(&self) -> TerminalKind { - self.0.kind - } - - #[napi( - getter, - js_name = "textLength", - ts_return_type = "cst.TextIndex", - catch_unwind - )] - pub fn text_len(&self) -> TextIndex { - let text_len: RustTextIndex = (&self.0.text).into(); - text_len.into() - } - - #[napi(getter, catch_unwind)] - pub fn text(&self) -> String { - self.0.text.clone() - } - - /// Serialize the node to JSON. - #[napi(catch_unwind, js_name = "toJSON")] - pub fn to_json(&self) -> String { - serde_json::to_string(&self.0).unwrap() - } - - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_cursor( - &self, - #[napi(ts_arg_type = "cst.TextIndex")] text_offset: TextIndex, - ) -> Cursor { - RustNode::Terminal(Rc::clone(&self.0)) - .cursor_with_offset(text_offset.into()) - .into() - } -} - -#[napi(namespace = "cst")] -pub struct Cursor(pub(super) RustCursor); - -impl From for Cursor { - fn from(value: RustCursor) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Cursor { - pub(crate) fn new(cursor: RustCursor) -> Self { - Self(cursor) - } - - #[napi(catch_unwind)] - pub fn reset(&mut self) { - self.0.reset(); - } - - #[napi(catch_unwind)] - pub fn complete(&mut self) { - self.0.complete(); - } - - #[must_use] - #[napi(catch_unwind)] - #[allow(clippy::should_implement_trait)] // These are meant to be explicitly exposed to NAPI - pub fn clone(&self) -> Self { - Self(self.0.clone()) - } - - #[must_use] - #[napi(catch_unwind)] - pub fn spawn(&self) -> Self { - Self::new(self.0.spawn()) - } - - #[napi(getter, catch_unwind)] - pub fn is_completed(&self) -> bool { - self.0.is_completed() - } - - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn node(&self) -> Either { - self.0.node().into_js_either_node() - } - - #[napi(getter, ts_return_type = "cst.EdgeLabel", catch_unwind)] - pub fn label(&self) -> Option { - self.0.label() - } - - #[napi(getter, ts_return_type = "cst.TextIndex", catch_unwind)] - pub fn text_offset(&self) -> TextIndex { - self.0.text_offset().into() - } - - #[napi(getter, ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - #[allow(clippy::cast_possible_truncation)] // Cursor depth can't reasonably be larger than u32 - #[napi(getter, catch_unwind)] - pub fn depth(&self) -> u32 { - self.0.depth() as u32 - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn ancestors(&self) -> Vec { - self.0.ancestors().map(NonterminalNode).collect() - } - - #[napi(catch_unwind)] - pub fn go_to_next(&mut self) -> bool { - self.0.go_to_next() - } - - #[napi(catch_unwind)] - pub fn go_to_next_non_descendent(&mut self) -> bool { - self.0.go_to_next_non_descendent() - } - - #[napi(catch_unwind)] - pub fn go_to_previous(&mut self) -> bool { - self.0.go_to_previous() - } - - #[napi(catch_unwind)] - pub fn go_to_parent(&mut self) -> bool { - self.0.go_to_parent() - } - - #[napi(catch_unwind)] - pub fn go_to_first_child(&mut self) -> bool { - self.0.go_to_first_child() - } - - #[napi(catch_unwind)] - pub fn go_to_last_child(&mut self) -> bool { - self.0.go_to_last_child() - } - - #[napi(catch_unwind)] - pub fn go_to_nth_child(&mut self, child_number: u32) -> bool { - self.0.go_to_nth_child(child_number as usize) - } - - #[napi(catch_unwind)] - pub fn go_to_next_sibling(&mut self) -> bool { - self.0.go_to_next_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_previous_sibling(&mut self) -> bool { - self.0.go_to_previous_sibling() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal(&mut self) -> bool { - self.0.go_to_next_terminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.TerminalKind")] kind: TerminalKind, - ) -> bool { - self.0.go_to_next_terminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_terminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_terminal_with_kinds(&kinds) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal(&mut self) -> bool { - self.0.go_to_next_nonterminal() - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kind( - &mut self, - #[napi(ts_arg_type = "cst.NonterminalKind")] kind: NonterminalKind, - ) -> bool { - self.0.go_to_next_nonterminal_with_kind(kind) - } - - #[napi(catch_unwind)] - pub fn go_to_next_nonterminal_with_kinds( - &mut self, - #[napi(ts_arg_type = "Array")] kinds: Vec, - ) -> bool { - self.0.go_to_next_nonterminal_with_kinds(&kinds) - } -} - -#[napi(namespace = "cst")] -pub struct Query(RustQuery); - -impl From for Query { - fn from(value: RustQuery) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl Query { - #[napi(factory, catch_unwind)] - pub fn parse(text: String) -> napi::Result { - RustQuery::parse(text.as_str()).map_or_else( - |err| Err(napi::Error::from_reason(err.message)), - |query| Ok(query.into()), - ) - } -} - -#[napi(namespace = "cst")] -pub struct QueryMatchIterator(RustQueryMatchIterator); - -#[napi(object, namespace = "cst")] -pub struct QueryMatch { - pub query_number: u32, - #[napi(ts_type = "{ [key: string]: cst.Cursor[] }")] - pub captures: HashMap>>, -} - -impl QueryMatch { - fn new(env: Env, r#match: RustQueryMatch) -> napi::Result { - #[allow(clippy::cast_possible_truncation)] - let query_number = r#match.query_number as u32; - // transfer all of the captures eagerly on the assumption - // that they've all been explicitly requested. - let captures = r#match - .captures - .into_iter() - .map(|(key, values)| { - let instances = values - .into_iter() - .map(|cursor| Cursor(cursor).into_instance(env)) - .collect::>()?; - - Ok((key, instances)) - }) - .collect::>()?; - - Ok(Self { - query_number, - captures, - }) - } -} - -impl From for QueryMatchIterator { - fn from(value: RustQueryMatchIterator) -> Self { - Self(value) - } -} - -#[napi(namespace = "cst")] -impl QueryMatchIterator { - #[napi(catch_unwind)] - pub fn next(&mut self, env: Env) -> napi::Result> { - match self.0.next() { - Some(r#match) => Ok(Some(QueryMatch::new(env, r#match)?)), - None => Ok(None), - } - } -} - -#[napi(namespace = "cst")] -impl Cursor { - #[napi(ts_return_type = "cst.QueryMatchIterator", catch_unwind)] - pub fn query( - &self, - #[napi(ts_arg_type = "Array")] queries: Vec<&Query>, - ) -> QueryMatchIterator { - self.0 - .clone() - .query(queries.into_iter().map(|x| x.0.clone()).collect()) - .into() - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextIndex { - pub utf8: u32, - pub utf16: u32, - pub line: u32, - pub column: u32, -} - -impl From for TextIndex { - fn from(value: RustTextIndex) -> Self { - // We only support 32-byte indices on TS side. - #[allow(clippy::cast_possible_truncation)] - Self { - utf8: value.utf8 as u32, - utf16: value.utf16 as u32, - line: value.line as u32, - column: value.column as u32, - } - } -} - -impl From for RustTextIndex { - fn from(value: TextIndex) -> Self { - Self { - utf8: value.utf8 as usize, - utf16: value.utf16 as usize, - line: value.line as usize, - column: value.column as usize, - } - } -} - -#[napi(object, namespace = "cst")] -#[derive(Copy, Clone)] -pub struct TextRange { - pub start: TextIndex, - pub end: TextIndex, -} - -impl From for TextRange { - fn from(value: RustTextRange) -> Self { - Self { - start: value.start.into(), - end: value.end.into(), - } - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs deleted file mode 100644 index 36f389892d..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/diagnostic.rs +++ /dev/null @@ -1,80 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use napi_derive::napi; - -use crate::napi_interface::cst::TextRange; - -/// Severity of the compiler diagnostic. -/// -/// Explicitly compatible with the LSP protocol. -#[napi(namespace = "diagnostic")] -pub enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, -} - -impl From for Severity { - fn from(value: crate::diagnostic::Severity) -> Severity { - match value { - crate::diagnostic::Severity::Error => Self::Error, - crate::diagnostic::Severity::Warning => Self::Warning, - crate::diagnostic::Severity::Information => Self::Information, - crate::diagnostic::Severity::Hint => Self::Hint, - } - } -} - -/// A compiler diagnostic that can be rendered to a user. -#[napi(namespace = "diagnostic")] -pub struct Diagnostic(pub(crate) Box); - -#[napi(namespace = "diagnostic")] -impl Diagnostic { - /// The severity of this diagnostic. - #[napi] - pub fn severity(&self) -> Severity { - self.0.severity().into() - } - - /// The character range of the source that this diagnostic applies to. - #[napi(ts_return_type = "cst.TextRange")] - pub fn text_range(&self) -> TextRange { - self.0.text_range().into() - } - - /// The primary message associated with this diagnostic. - #[napi] - pub fn message(&self) -> String { - self.0.message() - } -} - -/// Exposes the [`Diagnostic`](crate::diagnostic::Diagnostic) methods implemented for a given type -/// as regular N-API functions, satisfying the custom `DiagnosticInterface` interface on the N-API side. -// NOTE(#987): This is required because we can't directly expose the trait using `#[napi]` or expose -// an interface that has only methods defined. -// To not require explicit conversions, we define the interface ourselves and expose the relevant methods to satisfy it. -#[macro_export] -macro_rules! expose_diagnostic_trait_interface { - ($namespace:literal, $diagnostic:ty) => { - #[napi(namespace = $namespace)] - impl $diagnostic { - #[napi(ts_return_type = "diagnostic.Severity", catch_unwind)] - pub fn severity(&self) -> $crate::napi_interface::diagnostic::Severity { - $crate::diagnostic::Diagnostic::severity(&self.0).into() - } - - #[napi(ts_return_type = "cst.TextRange", catch_unwind)] - pub fn text_range(&self) -> $crate::napi_interface::cst::TextRange { - $crate::diagnostic::Diagnostic::text_range(&self.0).into() - } - - #[napi] - pub fn message(&self) -> String { - $crate::diagnostic::Diagnostic::message(&self.0) - } - } - }; -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs deleted file mode 100644 index 494395cbfc..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/generated/ast_selectors.rs +++ /dev/null @@ -1,262 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#![allow(clippy::too_many_lines)] // large match statements for all non-terminals -#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling - -use std::rc::Rc; - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::{EdgeLabel, NonterminalKind, RustEdge, RustNode, RustNonterminalNode}; - -// -// Sequences: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_sequence( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - let mut selector = Selector::new(node); - - let result = match node.kind() { - NonterminalKind::SourceUnit => selector.source_unit_sequence()?, - NonterminalKind::Tree => selector.tree_sequence()?, - NonterminalKind::TreeNode => selector.tree_node_sequence()?, - NonterminalKind::AdditionExpression => selector.addition_expression_sequence()?, - NonterminalKind::NegationExpression => selector.negation_expression_sequence()?, - NonterminalKind::MemberAccessExpression => selector.member_access_expression_sequence()?, - _ => { - return Error::UnexpectedParent(node.kind()).into(); - } - }; - - selector.finalize()?; - Ok(result) -} -impl Selector { - fn source_unit_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![Some(self.select(EdgeLabel::Members)?)]) - } -} - -impl Selector { - fn tree_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Keyword)?), - self.try_select(EdgeLabel::Name), - Some(self.select(EdgeLabel::Node)?), - Some(self.select(EdgeLabel::Semicolon)?), - ]) - } -} - -impl Selector { - fn tree_node_sequence(&mut self) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::OpenBracket)?), - Some(self.select(EdgeLabel::Members)?), - Some(self.select(EdgeLabel::CloseBracket)?), - ]) - } -} - -impl Selector { - fn addition_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::LeftOperand)?), - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::RightOperand)?), - ]) - } -} - -impl Selector { - fn negation_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operator)?), - Some(self.select(EdgeLabel::Operand)?), - ]) - } -} - -impl Selector { - fn member_access_expression_sequence( - &mut self, - ) -> Result>>> { - Ok(vec![ - Some(self.select(EdgeLabel::Operand)?), - Some(self.select(EdgeLabel::Period)?), - Some(self.select(EdgeLabel::Member)?), - ]) - } -} -// -// Choices: -// - -#[napi(namespace = "ast_internal", ts_return_type = "cst.Node", catch_unwind)] -pub fn select_choice( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result> { - let mut selector = Selector::new(node); - - let variant = selector.select(EdgeLabel::Variant)?; - - selector.finalize()?; - Ok(variant) -} - -// -// Repeated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "Array", - catch_unwind -)] -pub fn select_repeated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>> { - let mut selector = Selector::new(node); - - let mut items = vec![]; - - while let Some(item) = selector.try_select(EdgeLabel::Item) { - items.push(item); - } - - selector.finalize()?; - Ok(items) -} - -// -// Separated: -// - -#[napi( - namespace = "ast_internal", - ts_return_type = "[Array, Array]", - catch_unwind -)] -pub fn select_separated( - #[napi(ts_arg_type = "cst.NonterminalNode")] node: &NonterminalNode, -) -> Result>>> { - let mut selector = Selector::new(node); - - let mut items = vec![]; - let mut separators = vec![]; - - if let Some(first) = selector.try_select(EdgeLabel::Item) { - items.push(first); - - while let Some(separator) = selector.try_select(EdgeLabel::Separator) { - separators.push(separator); - - items.push(selector.select(EdgeLabel::Item)?); - } - } - - selector.finalize()?; - Ok(vec![items, separators]) -} - -// -// Common: -// - -struct Selector { - node: Rc, - index: usize, -} - -impl Selector { - fn new(node: &NonterminalNode) -> Self { - Self { - node: Rc::clone(&node.0), - index: 0, - } - } - - fn select(&mut self, target_label: EdgeLabel) -> Result> { - match self.try_select(target_label) { - Some(node) => Ok(node), - None => Error::MissingChild(target_label).into(), - } - } - - fn try_select( - &mut self, - target_label: EdgeLabel, - ) -> Option> { - let (label, node) = self.current()?; - - if label == target_label { - self.index += 1; - Some(node.clone().into_js_either_node()) - } else { - None - } - } - - fn current(&mut self) -> Option<(EdgeLabel, RustNode)> { - loop { - let RustEdge { label, node } = self.node.children.get(self.index)?; - - match label { - // Skip unlabeled nodes: - | None - // Skip trivia: - | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { - self.index += 1; - continue; - } - // Otherwise, return the edge: - Some(other_label) => { - return Some((*other_label, node.clone())); - } - } - } - } - - fn finalize(mut self) -> Result<()> { - match self.current() { - Some((label, _)) => Error::UnrecognizedChild(label).into(), - _ => Ok(()), - } - } -} - -type Result = std::result::Result; - -#[derive(Debug, thiserror::Error)] -enum Error { - // Should not theoretically happen, since we're only called from our own generated AST types. - #[error("Unexpected parent node with NonterminalKind '{0}'.")] - UnexpectedParent(NonterminalKind), - - #[error("Unrecognized child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - UnrecognizedChild(EdgeLabel), - - #[error("Missing child with label '{0}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")] - MissingChild(EdgeLabel), -} - -impl From for Result { - fn from(error: Error) -> Self { - Err(napi::Error::from_reason(error.to_string())) - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs deleted file mode 100644 index 681bf04f2a..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -pub mod cst; -pub mod diagnostic; -pub mod parser; - -#[path = "generated/ast_selectors.rs"] -pub mod ast_selectors; - -type RustCursor = crate::cst::Cursor; -type RustEdge = crate::cst::Edge; -type RustNode = crate::cst::Node; -type RustParseError = crate::parser::ParseError; -type RustParseOutput = crate::parser::ParseOutput; -type RustQuery = crate::cst::Query; -type RustQueryMatch = crate::cst::QueryMatch; -type RustQueryMatchIterator = crate::cst::QueryMatchIterator; -type RustNonterminalNode = crate::cst::NonterminalNode; -type RustTextIndex = crate::cst::TextIndex; -type RustTextRange = crate::cst::TextRange; -type RustTerminalNode = crate::cst::TerminalNode; - -type NonterminalKind = crate::cst::NonterminalKind; -type TerminalKind = crate::cst::TerminalKind; -type EdgeLabel = crate::cst::EdgeLabel; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/mod.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/mod.rs deleted file mode 100644 index 0623fb565d..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -mod parse_error; -mod parse_output; - -pub use parse_error::ParseError; -pub use parse_output::ParseOutput; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_error.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_error.rs deleted file mode 100644 index a7f67442e9..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_error.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// NAPI-exposed functions have to accept owned values. -#![allow(clippy::needless_pass_by_value)] - -use napi_derive::napi; - -use crate::expose_diagnostic_trait_interface; -use crate::napi_interface::RustParseError; - -#[napi(namespace = "parser")] -#[derive(PartialEq, Clone)] -pub struct ParseError(RustParseError); - -impl From for ParseError { - fn from(value: RustParseError) -> Self { - Self(value) - } -} - -expose_diagnostic_trait_interface!("parser", ParseError); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_output.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_output.rs deleted file mode 100644 index 455c2ac8ea..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/parser/parse_output.rs +++ /dev/null @@ -1,41 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use napi::Either; -use napi_derive::napi; - -use crate::napi_interface::cst::{Cursor, NAPINodeExtensions, NonterminalNode, TerminalNode}; -use crate::napi_interface::parser::ParseError; -use crate::napi_interface::RustParseOutput; - -#[napi(namespace = "parser")] -pub struct ParseOutput(RustParseOutput); - -impl From for ParseOutput { - fn from(value: RustParseOutput) -> Self { - Self(value) - } -} - -#[napi(namespace = "parser")] -impl ParseOutput { - #[napi(ts_return_type = "cst.Node", catch_unwind)] - pub fn tree(&self) -> Either { - self.0.tree().into_js_either_node() - } - - #[napi(ts_return_type = "Array", catch_unwind)] - pub fn errors(&self) -> Vec { - self.0.errors().iter().map(|x| x.clone().into()).collect() - } - - #[napi(getter, catch_unwind)] - pub fn is_valid(&self) -> bool { - self.0.is_valid() - } - - /// Creates a cursor that starts at the root of the parse tree. - #[napi(ts_return_type = "cst.Cursor", catch_unwind)] - pub fn create_tree_cursor(&self) -> Cursor { - self.0.create_tree_cursor().into() - } -} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_types.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_types.rs deleted file mode 100644 index 70d68c5abc..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/_types.rs +++ /dev/null @@ -1,8 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. -// You can use 'cargo expand' to see its output, or run the CLI version directly of 'wit-bindgen' via: -// -// wit-bindgen rust "./generated" --pub-export-macro --out-dir "./target/wit/" - -wit_bindgen::generate!(in "src/generated/wit/interface/generated"); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/diagnostic.wit b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/diagnostic.wit deleted file mode 100644 index 000fcaf719..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/diagnostic.wit +++ /dev/null @@ -1,10 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -interface diagnostic { - enum severity { - error, - warning, - information, - hint, - } -} 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 deleted file mode 100644 index 900317ef19..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -#[path = "./interface/generated/_types.rs"] -mod interface; -mod utils; -mod wrappers; - -struct World; - -crate::wit::interface::export!(World with_types_in crate::wit::interface); diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/diagnostic.rs b/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/diagnostic.rs deleted file mode 100644 index 51af0b9885..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/diagnostic.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -use crate::wit::utils::enum_to_enum; - -mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; -} - -mod rust { - pub use crate::diagnostic::Severity; -} - -//================================================ -// -// enum severity -// -//================================================ - -enum_to_enum!(Severity); diff --git a/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml b/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml deleted file mode 100644 index 7e2069eac8..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang_node_addon/Cargo.toml +++ /dev/null @@ -1,51 +0,0 @@ -[package] -name = "slang_testlang_node_addon" -version.workspace = true -rust-version.workspace = true -edition.workspace = true -publish = false - -description = "slang_testlang compiled as a cdylib crate, to be used as Node.js addon." - -# At the time of writing, building cdylib/plugins with Cargo has limited support -# (see for the general tracking issue). -# To workaround some of the issues, we create a synthetic crate that shares the same code as the original Rust crate -# but only exposes a `cdylib` library. -# There are a couple of things at play here: -# - To build a Node addon, we need to build a standalone cdylib, that's set up to expect host `napi_*` functions at runtime -# - `napi build` does that for us but only supports `cdylib` for the `lib` targets (e.g. not bin/examples) -# - expansion of #[napi] macros is enabled behind a feature flag; it expands the code that expects the host functions -# - while `napi/noop` feature exists that disables that, we test in workspace with `--all-features` and Cargo features are additive -# - thus, they get conflated and so the regular `rlib` library target gets built with the host functions expectation -# - ...which reasonably fails to link when `rlib` library is used as a regular Rust library (i.e. not in Node environment). -# Another workaround is to use an example with `cdylib` crate-type (wouldn't conflate the features in a downstream usable -# library), but napi doesn't support that yet. -# Also see for a similar issue with PyO3. -[lib] -path = "../slang_testlang/src/lib.rs" -crate-type = ["cdylib"] - -# __RUST_NAPI_CRATE_FEATURES__ (keep in sync) -[features] -default = ["__private_napi_interfaces"] -__private_napi_interfaces = [ - # This enables '#[napi]' attributes on the Rust types imported via [lib.path] above. - "dep:serde_json", -] - -[build-dependencies] -napi-build = { workspace = true } - -[dependencies] -metaslang_cst = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } -semver = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true, optional = true } -strum = { workspace = true } -strum_macros = { workspace = true } -thiserror = { workspace = true } - -[lints] -workspace = true diff --git a/crates/testlang/outputs/cargo/slang_testlang_node_addon/build.rs b/crates/testlang/outputs/cargo/slang_testlang_node_addon/build.rs deleted file mode 100644 index bb9898efca..0000000000 --- a/crates/testlang/outputs/cargo/slang_testlang_node_addon/build.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[cfg(not(feature = "__private_napi_interfaces"))] -compile_error!("The whole point is to enable __private_napi_interfaces for this cdylib crate!"); - -fn main() { - napi_build::setup(); -} diff --git a/crates/testlang/outputs/cargo/tests/src/errors/mod.rs b/crates/testlang/outputs/cargo/tests/src/errors/mod.rs index d08d698a7d..f8ed0b0bb0 100644 --- a/crates/testlang/outputs/cargo/tests/src/errors/mod.rs +++ b/crates/testlang/outputs/cargo/tests/src/errors/mod.rs @@ -4,7 +4,7 @@ use slang_testlang::parser::Parser; #[test] fn unsupported_language_version() { let version = Version::parse("0.0.0").unwrap(); - let error = Parser::new(version).unwrap_err(); + let error = Parser::create(version).unwrap_err(); assert_eq!(error.to_string(), "Unsupported language version '0.0.0'."); } diff --git a/crates/testlang/outputs/cargo/tests/src/graph/mod.rs b/crates/testlang/outputs/cargo/tests/src/graph/mod.rs index c4ba18179b..da187539c8 100644 --- a/crates/testlang/outputs/cargo/tests/src/graph/mod.rs +++ b/crates/testlang/outputs/cargo/tests/src/graph/mod.rs @@ -8,7 +8,7 @@ use slang_testlang::parser::Parser; #[test] fn builds_a_graph() { let version = Version::parse("1.0.0").unwrap(); - let parser = Parser::new(version).unwrap(); + let parser = Parser::create(version).unwrap(); let msgb_source = r" @tree [Tree] { diff --git a/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs b/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs index 6bf086fe58..4ea49c31b4 100644 --- a/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs +++ b/crates/testlang/outputs/cargo/tests/src/query/parser_tests.rs @@ -57,7 +57,7 @@ fn test_parsing_error() { Ok(_) => panic!("Expected error"), Err(e) => { assert_eq!(e.message, "Parse error:\nexpected ']' at: \nAlt at: [_\n"); - assert_eq!((e.row, e.column), (0, 8)); + assert_eq!((e.line, e.column), (0, 8)); } } } @@ -73,7 +73,7 @@ fn test_parsing_error_with_invalid_edge_label() { e.message, "Parse error:\n'Name' is not a valid edge label at: Name: [_]]\n", ); - assert_eq!((e.row, e.column), (0, 12)); + assert_eq!((e.line, e.column), (0, 12)); } } } @@ -88,7 +88,7 @@ fn test_parsing_error_with_invalid_node_kind() { e.message, "Parse error:\n'tree_node' is not a valid node kind at: tree_node]]\n", ); - assert_eq!((e.row, e.column), (0, 7)); + assert_eq!((e.line, e.column), (0, 7)); } } } @@ -103,7 +103,7 @@ fn test_parsing_error_with_kind_beginning_with_underscore() { e.message, "Parse error:\n'_tree_node' is not a valid node kind at: _tree_node]]\n", ); - assert_eq!((e.row, e.column), (0, 7)); + assert_eq!((e.line, e.column), (0, 7)); } } } diff --git a/crates/testlang/outputs/cargo/wasm/Cargo.toml b/crates/testlang/outputs/cargo/wasm/Cargo.toml new file mode 100644 index 0000000000..cb5dc8e8e9 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "testlang_cargo_wasm" +version.workspace = true +rust-version.workspace = true +edition.workspace = true +publish = false + +# At the time of writing, building 'cdylib' plugins with Cargo has limited support +# (see for the general tracking issue). +# To workaround some of the issues, we create a separate 'cdylib' crate that defines the WASM wrappers. +[lib] +crate-type = ["cdylib"] + +[build-dependencies] +anyhow = { workspace = true } +codegen_runtime_generator = { workspace = true } +infra_utils = { workspace = true } +testlang_language = { workspace = true } + +[dependencies] +paste = { workspace = true } +semver = { workspace = true } +serde_json = { workspace = true } +slang_testlang = { workspace = true } +wit-bindgen = { workspace = true } + +[lints] +workspace = true diff --git a/crates/testlang/outputs/cargo/wasm/build.rs b/crates/testlang/outputs/cargo/wasm/build.rs new file mode 100644 index 0000000000..9071da026f --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/build.rs @@ -0,0 +1,16 @@ +use anyhow::Result; +use codegen_runtime_generator::RuntimeGenerator; +use infra_utils::cargo::CargoWorkspace; +use testlang_language::TestlangDefinition; + +fn main() -> Result<()> { + let language = TestlangDefinition::create(); + + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_cargo_wasm")?.join("src/runtime"); + + let output_dir = + CargoWorkspace::locate_source_crate("testlang_cargo_wasm")?.join("src/generated"); + + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) +} diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/generated/bindings.rs b/crates/testlang/outputs/cargo/wasm/src/generated/generated/bindings.rs new file mode 100644 index 0000000000..db8654633f --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/generated/bindings.rs @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +// The `generate!()` macro below expands into the Rust bindings to be implemented by our wrappers. +// You can use 'cargo expand' to see its output, or run the 'wit-bindgen rust' command. + +wit_bindgen::generate!(in "src/generated/interface/generated"); diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/generated/config.json b/crates/testlang/outputs/cargo/wasm/src/generated/generated/config.json new file mode 100644 index 0000000000..f642396029 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/generated/config.json @@ -0,0 +1,139 @@ +{ + "mappings": { + "nomic-foundation:slang:cst:terminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:nonterminal-kind": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:edge-label": { + "Enum": { + "as_typescript_enum": true + } + }, + "nomic-foundation:slang:cst:node": { + "Variant": { + "as_direct_union_of_resource_classes": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:nonterminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node": { + "Resource": { + "custom_inspect": true + } + }, + "nomic-foundation:slang:cst:terminal-node.id()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.kind()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.text-length()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:terminal-node.children()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.node()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.label()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-offset()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.depth()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:cursor.ancestors()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:cst:query-match.captures": { + "ListOfTuple": { + "as_dictionary": true + } + }, + "nomic-foundation:slang:cst:query-match-iterator": { + "Resource": { + "as_iterator": true + } + }, + "nomic-foundation:slang:parser:parser.version()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.text-range()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-error.message()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.tree()": { + "Function": { + "as_getter": true + } + }, + "nomic-foundation:slang:parser:parse-output.errors()": { + "Function": { + "as_getter": true + } + } + } +} diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/ast.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/ast.wit new file mode 100644 index 0000000000..31c6a91f88 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/ast.wit @@ -0,0 +1,12 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +interface ast { + use cst.{node, nonterminal-node}; + + resource selectors { + sequence: static func(node: nonterminal-node) -> result>, string>; + choice: static func(node: nonterminal-node) -> result; + repeated: static func(node: nonterminal-node) -> result, string>; + separated: static func(node: nonterminal-node) -> result>, string>; + } +} diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/cst.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/cst.wit similarity index 85% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/cst.wit rename to crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/cst.wit index 01a97fe184..00664f1941 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/interface/generated/cst.wit +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/cst.wit @@ -17,6 +17,33 @@ interface cst { %tree-node-children, } + enum terminal-kind { + // Built-in: + unrecognized, + missing, + + // 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 terminal-kind-extensions { + is-trivia: static func(kind: terminal-kind) -> bool; + is-valid: static func(kind: terminal-kind) -> bool; + } + enum edge-label { // Built-in: %item, @@ -41,44 +68,36 @@ interface cst { %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, - } - variant node { nonterminal(nonterminal-node), terminal(terminal-node) } resource nonterminal-node { + id: func() -> u32; kind: func() -> nonterminal-kind; - text-len: func() -> text-index; - children: func() -> list; - create-cursor: func(text-offset: text-index) -> cursor; + text-length: func() -> text-index; + + children: func() -> list; unparse: func() -> string; + to-json: func() -> string; + + create-cursor: func(text-offset: text-index) -> cursor; } resource terminal-node { + id: func() -> u32; kind: func() -> terminal-kind; - text-len: func() -> text-index; - text: func() -> string; + text-length: func() -> text-index; + + children: func() -> list; + unparse: func() -> string; + to-json: func() -> string; + } + + record edge { + label: option, + node: node, } resource cursor { @@ -129,7 +148,7 @@ interface cst { record query-error { message: string, - row: u32, + line: u32, column: u32, } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/parser.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/parser.wit similarity index 83% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/parser.wit rename to crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/parser.wit index 8381cb836d..f5ae55423e 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/parser.wit +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/parser.wit @@ -2,17 +2,17 @@ interface parser { use cst.{cursor, node, nonterminal-kind, text-range}; - use diagnostic.{severity}; resource parser { + root-kind: static func() -> nonterminal-kind; supported-versions: static func() -> list; - new: static func(version: string) -> result; + create: static func(version: string) -> result; + version: func() -> string; parse: func(kind: nonterminal-kind, input: string) -> parse-output; } resource parse-error { - severity: func() -> severity; text-range: func() -> text-range; message: func() -> string; } diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_world.wit b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit similarity index 88% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_world.wit rename to crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit index 7f826767f4..c5e1378860 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/interface/generated/_world.wit +++ b/crates/testlang/outputs/cargo/wasm/src/generated/interface/generated/world.wit @@ -3,7 +3,7 @@ package nomic-foundation:slang; world slang { + export ast; export cst; - export diagnostic; export parser; } diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/mod.rs b/crates/testlang/outputs/cargo/wasm/src/generated/mod.rs new file mode 100644 index 0000000000..c84d868d87 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/mod.rs @@ -0,0 +1,10 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[path = "./generated/bindings.rs"] +mod bindings; +mod utils; +mod wrappers; + +struct World; + +crate::wasm_crate::bindings::export!(World with_types_in crate::wasm_crate::bindings); diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/utils.rs b/crates/testlang/outputs/cargo/wasm/src/generated/utils.rs similarity index 88% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/utils.rs rename to crates/testlang/outputs/cargo/wasm/src/generated/utils.rs index df09032699..fb8549efea 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/utils.rs +++ b/crates/testlang/outputs/cargo/wasm/src/generated/utils.rs @@ -14,14 +14,14 @@ macro_rules! define_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (rust::$name); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0 @@ -63,14 +63,14 @@ macro_rules! define_rc_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::rc::Rc); - impl $crate::wit::utils::IntoFFI for std::rc::Rc { + impl $crate::wasm_crate::utils::IntoFFI for std::rc::Rc { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](self)) } } - impl $crate::wit::utils::FromFFI> for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI> for ffi::$name { #[inline] fn _from_ffi(self) -> std::rc::Rc { self.into_inner::<[<$name Wrapper>]>().0 @@ -112,14 +112,14 @@ macro_rules! define_refcell_wrapper { #[repr(transparent)] pub struct [<$name Wrapper>] (std::cell::RefCell); - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { ffi::$name::new([<$name Wrapper>](std::cell::RefCell::new(self))) } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { self.into_inner::<[<$name Wrapper>]>().0.into_inner() @@ -169,14 +169,14 @@ macro_rules! define_refcell_wrapper { macro_rules! enum_to_enum { ($name:ident) => { - impl $crate::wit::utils::IntoFFI for rust::$name { + impl $crate::wasm_crate::utils::IntoFFI for rust::$name { #[inline] fn _into_ffi(self) -> ffi::$name { unsafe { core::mem::transmute(self) } } } - impl $crate::wit::utils::FromFFI for ffi::$name { + impl $crate::wasm_crate::utils::FromFFI for ffi::$name { #[inline] fn _from_ffi(self) -> rust::$name { unsafe { core::mem::transmute(self) } diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs new file mode 100644 index 0000000000..3d6c9619a9 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/generated/selectors.rs @@ -0,0 +1,216 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#![allow(clippy::too_many_lines)] // large match statements for all non-terminals +#![allow(clippy::unnecessary_wraps)] // using `Result` for all functions for error handling + +use std::rc::Rc; + +use crate::rust_crate::cst::{Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode}; + +// +// Sequences: +// + +pub fn select_sequence(node: &Rc) -> Result>> { + let mut helper = Helper::new(node); + + let result = match node.kind { + NonterminalKind::SourceUnit => helper.source_unit_sequence()?, + NonterminalKind::Tree => helper.tree_sequence()?, + NonterminalKind::TreeNode => helper.tree_node_sequence()?, + NonterminalKind::AdditionExpression => helper.addition_expression_sequence()?, + NonterminalKind::NegationExpression => helper.negation_expression_sequence()?, + NonterminalKind::MemberAccessExpression => helper.member_access_expression_sequence()?, + _ => { + // Should not theoretically happen, since we're only called from our own generated AST types. + return Err(format!( + "Unexpected parent node with NonterminalKind '{0}'.", + node.kind + )); + } + }; + + helper.finalize()?; + Ok(result) +} +impl Helper { + fn source_unit_sequence(&mut self) -> Result>> { + Ok(vec![Some(self.select(EdgeLabel::Members)?)]) + } +} + +impl Helper { + fn tree_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Keyword)?), + self.try_select(EdgeLabel::Name), + Some(self.select(EdgeLabel::Node)?), + Some(self.select(EdgeLabel::Semicolon)?), + ]) + } +} + +impl Helper { + fn tree_node_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::OpenBracket)?), + Some(self.select(EdgeLabel::Members)?), + Some(self.select(EdgeLabel::CloseBracket)?), + ]) + } +} + +impl Helper { + fn addition_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::LeftOperand)?), + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::RightOperand)?), + ]) + } +} + +impl Helper { + fn negation_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operator)?), + Some(self.select(EdgeLabel::Operand)?), + ]) + } +} + +impl Helper { + fn member_access_expression_sequence(&mut self) -> Result>> { + Ok(vec![ + Some(self.select(EdgeLabel::Operand)?), + Some(self.select(EdgeLabel::Period)?), + Some(self.select(EdgeLabel::Member)?), + ]) + } +} +// +// Choices: +// + +pub fn select_choice(node: &Rc) -> Result { + let mut helper = Helper::new(node); + + let variant = helper.select(EdgeLabel::Variant)?; + + helper.finalize()?; + Ok(variant) +} + +// +// Repeated: +// + +pub fn select_repeated(node: &Rc) -> Result> { + let mut helper = Helper::new(node); + + let mut items = vec![]; + + while let Some(item) = helper.try_select(EdgeLabel::Item) { + items.push(item); + } + + helper.finalize()?; + Ok(items) +} + +// +// Separated: +// + +pub fn select_separated(node: &Rc) -> Result>> { + let mut helper = Helper::new(node); + + let mut items = vec![]; + let mut separators = vec![]; + + if let Some(first) = helper.try_select(EdgeLabel::Item) { + items.push(first); + + while let Some(separator) = helper.try_select(EdgeLabel::Separator) { + separators.push(separator); + + items.push(helper.select(EdgeLabel::Item)?); + } + } + + helper.finalize()?; + Ok(vec![items, separators]) +} + +// +// Common: +// + +type Result = std::result::Result; + +struct Helper { + node: Rc, + index: usize, +} + +impl Helper { + fn new(node: &Rc) -> Self { + Self { + node: Rc::clone(node), + index: 0, + } + } + + fn select(&mut self, target_label: EdgeLabel) -> Result { + match self.try_select(target_label) { + Some(node) => { + Ok(node) + }, + None => { + Err(format!("Missing child with label '{target_label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + } + } + + fn try_select(&mut self, target_label: EdgeLabel) -> Option { + let (label, node) = self.current()?; + + if label == target_label { + self.index += 1; + Some(node.clone()) + } else { + None + } + } + + fn current(&mut self) -> Option<(EdgeLabel, Node)> { + loop { + let Edge { label, node } = self.node.children.get(self.index)?; + + match label { + // Skip unlabeled nodes: + | None + // Skip trivia: + | Some(EdgeLabel::LeadingTrivia | EdgeLabel::TrailingTrivia) => { + self.index += 1; + continue; + } + // Otherwise, return the edge: + Some(other_label) => { + return Some((*other_label, node.clone())); + } + } + } + } + + fn finalize(mut self) -> Result<()> { + match self.current() { + Some((label, _)) => { + Err(format!("Unrecognized child with label '{label}'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.")) + } + None => { + Ok(()) + }, + } + } +} diff --git a/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs new file mode 100644 index 0000000000..5b262a1782 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/ast/mod.rs @@ -0,0 +1,56 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +#[path = "generated/selectors.rs"] +mod selectors; + +use crate::wasm_crate::utils::IntoFFI; + +mod ffi { + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::ast::{ + Guest, GuestSelectors, + }; + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Node, NonterminalNode, + }; +} + +mod rust {} + +impl ffi::Guest for crate::wasm_crate::World { + type Selectors = SelectorsWrapper; +} + +//================================================ +// +// resource selectors +// +//================================================ + +pub struct SelectorsWrapper; + +impl ffi::GuestSelectors for SelectorsWrapper { + fn sequence(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_sequence(node._borrow_ffi())? + .into_iter() + .map(|opt| opt.map(|node| node._into_ffi())) + .collect()) + } + + fn choice(node: ffi::NonterminalNode) -> Result { + Ok(selectors::select_choice(node._borrow_ffi())?._into_ffi()) + } + + fn repeated(node: ffi::NonterminalNode) -> Result, String> { + Ok(selectors::select_repeated(node._borrow_ffi())? + .into_iter() + .map(|node| node._into_ffi()) + .collect()) + } + + fn separated(node: ffi::NonterminalNode) -> Result>, String> { + Ok(selectors::select_separated(node._borrow_ffi())? + .into_iter() + .map(|vec| vec.into_iter().map(|node| node._into_ffi()).collect()) + .collect()) + } +} diff --git a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/cst.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs similarity index 73% rename from crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/cst.rs rename to crates/testlang/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs index 8b99766aae..91c5285601 100644 --- a/crates/solidity/outputs/cargo/slang_solidity/src/generated/wit/wrappers/cst.rs +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/cst/mod.rs @@ -1,27 +1,29 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::wit::utils::{ +use crate::wasm_crate::utils::{ define_rc_wrapper, define_refcell_wrapper, define_wrapper, enum_to_enum, FromFFI, IntoFFI, }; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ - Cursor, CursorBorrow, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, GuestQuery, - GuestQueryMatchIterator, GuestTerminalNode, Node, NonterminalKind, NonterminalNode, - NonterminalNodeBorrow, Query, QueryBorrow, QueryError, QueryMatch, QueryMatchIterator, - QueryMatchIteratorBorrow, TerminalKind, TerminalNode, TerminalNodeBorrow, TextIndex, - TextRange, + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ + Cursor, CursorBorrow, Edge, EdgeLabel, Guest, GuestCursor, GuestNonterminalNode, + GuestQuery, GuestQueryMatchIterator, GuestTerminalKindExtensions, GuestTerminalNode, Node, + NonterminalKind, NonterminalNode, NonterminalNodeBorrow, Query, QueryBorrow, QueryError, + QueryMatch, QueryMatchIterator, QueryMatchIteratorBorrow, TerminalKind, TerminalNode, + TerminalNodeBorrow, TextIndex, TextRange, }; } mod rust { - pub use crate::cst::{ - Cursor, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, QueryMatch, - QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, + pub use crate::rust_crate::cst::{ + Cursor, Edge, EdgeLabel, Node, NonterminalKind, NonterminalNode, Query, QueryError, + QueryMatch, QueryMatchIterator, TerminalKind, TerminalNode, TextIndex, TextRange, }; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { + type TerminalKindExtensions = TerminalKindExtensionsWrapper; + type NonterminalNode = NonterminalNodeWrapper; type TerminalNode = TerminalNodeWrapper; @@ -47,6 +49,24 @@ enum_to_enum!(NonterminalKind); enum_to_enum!(TerminalKind); +//================================================ +// +// resource terminal-kind-extensions +// +//================================================ + +pub struct TerminalKindExtensionsWrapper; + +impl ffi::GuestTerminalKindExtensions for TerminalKindExtensionsWrapper { + fn is_trivia(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_trivia(&kind._from_ffi()) + } + + fn is_valid(kind: ffi::TerminalKind) -> bool { + crate::rust_crate::cst::TerminalKindExtensions::is_valid(&kind._from_ffi()) + } +} + //================================================ // // enum edge-label @@ -55,6 +75,22 @@ enum_to_enum!(TerminalKind); enum_to_enum!(EdgeLabel); +//================================================ +// +// 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()), + } + } +} + //================================================ // // resource nonterminal-node @@ -62,24 +98,32 @@ enum_to_enum!(EdgeLabel); //================================================ define_rc_wrapper! { NonterminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::NonterminalKind { self._borrow_ffi().kind._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { + fn text_length(&self) -> ffi::TextIndex { self._borrow_ffi().text_len._into_ffi() } - fn children(&self) -> Vec { - self._borrow_ffi().children.iter().map(|edge| edge.node.clone()._into_ffi()).collect() + fn children(&self) -> Vec { + self._borrow_ffi().children.iter().map(|edge| edge.clone()._into_ffi()).collect() } - 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 { + self._borrow_ffi().unparse() } - fn unparse(&self) -> String { - std::rc::Rc::clone(self._borrow_ffi()).unparse() + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() + } + + 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() } } } @@ -90,31 +134,43 @@ define_rc_wrapper! { NonterminalNode { //================================================ define_rc_wrapper! { TerminalNode { + fn id(&self) -> u32 { + self._borrow_ffi().id().try_into().unwrap() + } + fn kind(&self) -> ffi::TerminalKind { self._borrow_ffi().kind._into_ffi() } - fn text(&self) -> String { - self._borrow_ffi().text.clone() + fn text_length(&self) -> ffi::TextIndex { + rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() } - fn text_len(&self) -> ffi::TextIndex { - rust::TextIndex::from(&self._borrow_ffi().text)._into_ffi() + fn children(&self) -> Vec { + Vec::new() + } + + fn unparse(&self) -> String { + self._borrow_ffi().unparse() + } + + fn to_json(&self) -> String { + serde_json::to_string(&self._borrow_ffi()).unwrap() } } } //================================================ // -// variant node +// record edge // //================================================ -impl IntoFFI for rust::Node { +impl IntoFFI for rust::Edge { #[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()), + fn _into_ffi(self) -> ffi::Edge { + ffi::Edge { + label: self.label.map(|label| label._into_ffi()), + node: self.node._into_ffi(), } } } @@ -162,9 +218,8 @@ define_refcell_wrapper! { Cursor { self._borrow_ffi().text_range()._into_ffi() } - #[allow(clippy::cast_possible_truncation)] fn depth(&self) -> u32 { - self._borrow_ffi().depth() as u32 + self._borrow_ffi().depth().try_into().unwrap() } fn ancestors(&self) -> Vec { @@ -263,11 +318,10 @@ define_wrapper! { Query { impl IntoFFI for rust::QueryError { #[inline] fn _into_ffi(self) -> ffi::QueryError { - #[allow(clippy::cast_possible_truncation)] ffi::QueryError { message: self.message, - row: self.row as u32, - column: self.column as u32, + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } @@ -294,8 +348,7 @@ 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, + query_number: self.query_number.try_into().unwrap(), captures: self .captures .into_iter() @@ -311,27 +364,19 @@ impl IntoFFI for rust::QueryMatch { // //================================================ -impl IntoFFI for rust::TextIndex { +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, + utf8: self.utf8.try_into().unwrap(), + utf16: self.utf16.try_into().unwrap(), + line: self.line.try_into().unwrap(), + column: self.column.try_into().unwrap(), } } } -impl IntoFFI for &rust::TextIndex { - #[inline] - fn _into_ffi(self) -> ffi::TextIndex { - (*self)._into_ffi() - } -} - -impl FromFFI for ffi::TextIndex { +impl FromFFI for &ffi::TextIndex { #[inline] fn _from_ffi(self) -> rust::TextIndex { rust::TextIndex { @@ -349,16 +394,6 @@ impl FromFFI for ffi::TextIndex { // //================================================ -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 { @@ -369,7 +404,7 @@ impl IntoFFI for &rust::TextRange { } } -impl FromFFI for ffi::TextRange { +impl FromFFI for &ffi::TextRange { #[inline] fn _from_ffi(self) -> rust::TextRange { rust::TextRange { diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/mod.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/mod.rs similarity index 87% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/mod.rs rename to crates/testlang/outputs/cargo/wasm/src/generated/wrappers/mod.rs index 0bf0d41a7a..e05fee5635 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/mod.rs +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/mod.rs @@ -1,5 +1,5 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. +mod ast; mod cst; -mod diagnostic; mod parser; diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/parser.rs b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs similarity index 53% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/parser.rs rename to crates/testlang/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs index 56a33eb3ab..311c2b9d8a 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/wit/wrappers/parser.rs +++ b/crates/testlang/outputs/cargo/wasm/src/generated/wrappers/parser/mod.rs @@ -1,24 +1,22 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -use crate::diagnostic::Diagnostic; -use crate::wit::utils::{define_wrapper, FromFFI, IntoFFI}; +use crate::wasm_crate::utils::{define_wrapper, FromFFI, IntoFFI}; mod ffi { - pub use crate::wit::interface::exports::nomic_foundation::slang::cst::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::cst::{ Cursor, Node, TextRange, }; - pub use crate::wit::interface::exports::nomic_foundation::slang::diagnostic::Severity; - pub use crate::wit::interface::exports::nomic_foundation::slang::parser::{ + pub use crate::wasm_crate::bindings::exports::nomic_foundation::slang::parser::{ Guest, GuestParseError, GuestParseOutput, GuestParser, NonterminalKind, ParseError, ParseErrorBorrow, ParseOutput, ParseOutputBorrow, Parser, ParserBorrow, }; } mod rust { - pub use crate::parser::{ParseError, ParseOutput, Parser}; + pub use crate::rust_crate::parser::{ParseError, ParseOutput, Parser}; } -impl ffi::Guest for crate::wit::World { +impl ffi::Guest for crate::wasm_crate::World { type Parser = ParserWrapper; type ParseError = ParseErrorWrapper; type ParseOutput = ParseOutputWrapper; @@ -31,15 +29,8 @@ impl ffi::Guest for crate::wit::World { //================================================ define_wrapper! { Parser { - fn new(version: String) -> Result { - semver::Version::parse(&version) - .map_err(|_| format!("Invalid version: {version}")) - .and_then(|version| rust::Parser::new(version).map_err(|e| e.to_string())) - .map(IntoFFI::_into_ffi) - } - - fn version(&self) -> String { - self._borrow_ffi().version.to_string() + fn root_kind() -> ffi::NonterminalKind { + rust::Parser::ROOT_KIND._into_ffi() } fn supported_versions() -> Vec { @@ -49,6 +40,17 @@ define_wrapper! { Parser { .collect() } + fn create(version: String) -> Result { + semver::Version::parse(&version) + .map_err(|_| format!("Invalid semantic version: '{version}'")) + .and_then(|version| rust::Parser::create(version).map_err(|e| e.to_string())) + .map(IntoFFI::_into_ffi) + } + + fn version(&self) -> String { + self._borrow_ffi().version.to_string() + } + fn parse(&self, kind: ffi::NonterminalKind, input: String) -> ffi::ParseOutput { self._borrow_ffi().parse(kind._from_ffi(), &input)._into_ffi() } @@ -61,17 +63,13 @@ define_wrapper! { Parser { //================================================ 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 text_range(&self) -> ffi::TextRange { + self._borrow_ffi().text_range()._into_ffi() + } - fn message(&self) -> String { - self._borrow_ffi().message() - } + fn message(&self) -> String { + self._borrow_ffi().message() + } } } //================================================ @@ -81,19 +79,19 @@ define_wrapper! { ParseError { //================================================ define_wrapper! { ParseOutput { - fn tree(&self) -> ffi::Node { - self._borrow_ffi().tree()._into_ffi() - } + 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 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 is_valid(&self) -> bool { + self._borrow_ffi().is_valid() + } - fn create_tree_cursor(&self) -> ffi::Cursor { - self._borrow_ffi().create_tree_cursor()._into_ffi() - } + fn create_tree_cursor(&self) -> ffi::Cursor { + self._borrow_ffi().create_tree_cursor()._into_ffi() + } } } diff --git a/crates/testlang/outputs/cargo/wasm/src/lib.rs b/crates/testlang/outputs/cargo/wasm/src/lib.rs new file mode 100644 index 0000000000..f9ad4c60d6 --- /dev/null +++ b/crates/testlang/outputs/cargo/wasm/src/lib.rs @@ -0,0 +1,3 @@ +mod generated; + +use {generated as wasm_crate, slang_testlang as rust_crate}; diff --git a/crates/testlang/outputs/npm/package/.gitignore b/crates/testlang/outputs/npm/package/.gitignore new file mode 100644 index 0000000000..53571f1f92 --- /dev/null +++ b/crates/testlang/outputs/npm/package/.gitignore @@ -0,0 +1,3 @@ +# WASM binaries and bindgen files generated during the build: +wasm/generated/*.js +wasm/generated/*.wasm diff --git a/crates/testlang/outputs/npm/package/build.rs b/crates/testlang/outputs/npm/package/build.rs index 62c0a20f2b..95e6de6e63 100644 --- a/crates/testlang/outputs/npm/package/build.rs +++ b/crates/testlang/outputs/npm/package/build.rs @@ -1,13 +1,16 @@ use anyhow::Result; -use codegen_runtime_generator::OutputLanguage; +use codegen_runtime_generator::RuntimeGenerator; use infra_utils::cargo::CargoWorkspace; use testlang_language::TestlangDefinition; fn main() -> Result<()> { let language = TestlangDefinition::create(); + let input_dir = + CargoWorkspace::locate_source_crate("codegen_runtime_npm_package")?.join("src/runtime"); + let output_dir = CargoWorkspace::locate_source_crate("testlang_npm_package")?.join("src/generated"); - OutputLanguage::Npm.generate_runtime(&language, &output_dir) + RuntimeGenerator::generate_product(&language, &input_dir, &output_dir) } diff --git a/crates/testlang/outputs/npm/package/package.json b/crates/testlang/outputs/npm/package/package.json index f3a6d772ea..350ae6f5e9 100644 --- a/crates/testlang/outputs/npm/package/package.json +++ b/crates/testlang/outputs/npm/package/package.json @@ -1,17 +1,16 @@ { - "name": "@slang-private/slang-testlang", + "name": "@slang-private/testlang-npm-package", "private": true, - "type": "commonjs", - "devDependencies": { - "@napi-rs/cli": "2.18.4" + "type": "module", + "__exports_comment__": "__SLANG_NPM_PACKAGE_EXPORTS__ (keep in sync)", + "exports": { + ".": "./target/generated/index.mjs", + "./ast": "./target/generated/ast/index.mjs", + "./cst": "./target/generated/cst/index.mjs", + "./parser": "./target/generated/parser/index.mjs" }, - "napi": { - "triples": { - "defaults": false, - "additional": [] - } - }, - "engines": { - "node": ">= 10" + "__dependencies_comment__": "__SLANG_NPM_PACKAGE_DEPENDENCIES__ (keep in sync)", + "dependencies": { + "@bytecodealliance/preview2-shim": "0.17.0" } } diff --git a/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts b/crates/testlang/outputs/npm/package/src/generated/ast/generated/nodes.mts similarity index 81% rename from crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts rename to crates/testlang/outputs/npm/package/src/generated/ast/generated/nodes.mts index 57a151ad80..7cd4e5d861 100644 --- a/crates/testlang/outputs/npm/package/src/generated/ast/generated/ast_types.ts +++ b/crates/testlang/outputs/npm/package/src/generated/ast/generated/nodes.mts @@ -1,8 +1,7 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -import * as assert from "node:assert"; -import { ast_internal } from "../../napi-bindings/generated"; -import { NodeType, NonterminalKind, NonterminalNode, TerminalNode } from "../../cst"; +import * as generated from "../../../../wasm/index.mjs"; +import { NonterminalKind, NonterminalNode, TerminalNode } from "../../cst/index.mjs"; /* * Sequences: @@ -10,7 +9,7 @@ import { NodeType, NonterminalKind, NonterminalNode, TerminalNode } from "../../ export class SourceUnit { private readonly fetch = once(() => { - const [$members] = ast_internal.selectSequence(this.cst); + const [$members] = generated.ast.Selectors.sequence(this.cst); return { members: new SourceUnitMembers($members as NonterminalNode), @@ -28,11 +27,11 @@ export class SourceUnit { export class Tree { private readonly fetch = once(() => { - const [$keyword, $name, $node, $semicolon] = ast_internal.selectSequence(this.cst); + const [$keyword, $name, $node, $semicolon] = generated.ast.Selectors.sequence(this.cst); return { keyword: $keyword as TerminalNode, - name: $name === null ? undefined : ($name as TerminalNode), + name: $name === undefined ? undefined : ($name as TerminalNode), node: new TreeNode($node as NonterminalNode), semicolon: $semicolon as TerminalNode, }; @@ -61,7 +60,7 @@ export class Tree { export class TreeNode { private readonly fetch = once(() => { - const [$openBracket, $members, $closeBracket] = ast_internal.selectSequence(this.cst); + const [$openBracket, $members, $closeBracket] = generated.ast.Selectors.sequence(this.cst); return { openBracket: $openBracket as TerminalNode, @@ -89,7 +88,7 @@ export class TreeNode { export class AdditionExpression { private readonly fetch = once(() => { - const [$leftOperand, $operator, $rightOperand] = ast_internal.selectSequence(this.cst); + const [$leftOperand, $operator, $rightOperand] = generated.ast.Selectors.sequence(this.cst); return { leftOperand: new Expression($leftOperand as NonterminalNode), @@ -117,7 +116,7 @@ export class AdditionExpression { export class NegationExpression { private readonly fetch = once(() => { - const [$operator, $operand] = ast_internal.selectSequence(this.cst); + const [$operator, $operand] = generated.ast.Selectors.sequence(this.cst); return { operator: $operator as TerminalNode, @@ -140,7 +139,7 @@ export class NegationExpression { export class MemberAccessExpression { private readonly fetch = once(() => { - const [$operand, $period, $member] = ast_internal.selectSequence(this.cst); + const [$operand, $period, $member] = generated.ast.Selectors.sequence(this.cst); return { operand: new Expression($operand as NonterminalNode), @@ -172,7 +171,7 @@ export class MemberAccessExpression { export class SourceUnitMember { private readonly fetch: () => Tree | Expression | SeparatedIdentifiers | Literal = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); switch (variant.kind) { case NonterminalKind.Tree: @@ -185,7 +184,7 @@ export class SourceUnitMember { return new Literal(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -200,10 +199,10 @@ export class SourceUnitMember { export class TreeNodeChild { private readonly fetch: () => TreeNode | TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -211,7 +210,7 @@ export class TreeNodeChild { return new TreeNode(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }); @@ -227,10 +226,10 @@ export class TreeNodeChild { export class Expression { private readonly fetch: () => AdditionExpression | NegationExpression | MemberAccessExpression | TerminalNode = once( () => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); - if (variant.type == NodeType.Terminal) { - return variant as TerminalNode; + if (variant.isTerminalNode()) { + return variant; } switch (variant.kind) { @@ -242,7 +241,7 @@ export class Expression { return new MemberAccessExpression(variant as NonterminalNode); default: - assert.fail(`Unexpected variant: ${variant.kind}`); + throw new Error(`Unexpected variant: '${variant.kind}'.`); } }, ); @@ -258,7 +257,7 @@ export class Expression { export class Literal { private readonly fetch: () => TerminalNode = once(() => { - const variant = ast_internal.selectChoice(this.cst); + const variant = generated.ast.Selectors.choice(this.cst); return variant as TerminalNode; }); @@ -278,7 +277,7 @@ export class Literal { export class SourceUnitMembers { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new SourceUnitMember(item as NonterminalNode)); }); @@ -293,7 +292,7 @@ export class SourceUnitMembers { export class TreeNodeChildren { private readonly fetch = once(() => { - const items = ast_internal.selectRepeated(this.cst); + const items = generated.ast.Selectors.repeated(this.cst); return items.map((item) => new TreeNodeChild(item as NonterminalNode)); }); @@ -312,7 +311,7 @@ export class TreeNodeChildren { export class SeparatedIdentifiers { private readonly fetch = once(() => { - const [items, separators] = ast_internal.selectSeparated(this.cst); + const [items, separators] = generated.ast.Selectors.separated(this.cst); return { items: items as TerminalNode[], separators: separators as TerminalNode[] }; }); @@ -345,5 +344,9 @@ function once(factory: () => T): () => T { } function assertKind(actual: NonterminalKind, expected: NonterminalKind): void { - assert.equal(actual, expected, `${expected} can only be initialized with a CST node of the same kind.`); + if (actual !== expected) { + throw new Error( + `AST node '${expected}' can only be initialized with a CST node of the same kind. Received '${actual}' instead.`, + ); + } } diff --git a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs b/crates/testlang/outputs/npm/package/src/generated/ast/index.mts similarity index 70% rename from crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs rename to crates/testlang/outputs/npm/package/src/generated/ast/index.mts index 60ba962444..f4e4da9201 100644 --- a/crates/testlang/outputs/cargo/slang_testlang/src/generated/cli/commands/mod.rs +++ b/crates/testlang/outputs/npm/package/src/generated/ast/index.mts @@ -1,3 +1,3 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -pub mod parse; +export * from "./generated/nodes.mjs"; diff --git a/crates/testlang/outputs/npm/package/src/generated/ast/index.ts b/crates/testlang/outputs/npm/package/src/generated/ast/index.ts deleted file mode 100644 index e92970e319..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/ast/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -export * from "./generated/ast_types"; diff --git a/crates/testlang/outputs/npm/package/src/generated/cst/index.mts b/crates/testlang/outputs/npm/package/src/generated/cst/index.mts new file mode 100644 index 0000000000..3bab65460e --- /dev/null +++ b/crates/testlang/outputs/npm/package/src/generated/cst/index.mts @@ -0,0 +1,81 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +import * as generated from "../../../wasm/index.mjs"; + +export const NonterminalKind = generated.cst.NonterminalKind; +export type NonterminalKind = generated.cst.NonterminalKind; + +export const TerminalKind = generated.cst.TerminalKind; +export type TerminalKind = generated.cst.TerminalKind; + +export const TerminalKindExtensions = generated.cst.TerminalKindExtensions; +export type TerminalKindExtensions = generated.cst.TerminalKindExtensions; + +export const EdgeLabel = generated.cst.EdgeLabel; +export type EdgeLabel = generated.cst.EdgeLabel; + +export type Node = generated.cst.Node; + +export const NodeVariant = generated.cst.NodeVariant; +export type NodeVariant = generated.cst.NodeVariant; + +export const NonterminalNode = generated.cst.NonterminalNode; +export type NonterminalNode = generated.cst.NonterminalNode; + +export const TerminalNode = generated.cst.TerminalNode; +export type TerminalNode = generated.cst.TerminalNode; + +export type Edge = generated.cst.Edge; + +export const Cursor = generated.cst.Cursor; +export type Cursor = generated.cst.Cursor; + +export const Query = generated.cst.Query; +export type Query = generated.cst.Query; + +export type QueryError = generated.cst.QueryError; + +export type QueryMatch = generated.cst.QueryMatch; + +export const QueryMatchIterator = generated.cst.QueryMatchIterator; +export type QueryMatchIterator = generated.cst.QueryMatchIterator; + +export type TextIndex = generated.cst.TextIndex; + +export type TextRange = generated.cst.TextRange; + +/* + * Helpers: + */ + +export function assertIsNonterminalNode( + node: unknown, + kind?: NonterminalKind, + text?: string, +): asserts node is NonterminalNode { + if (!(node instanceof NonterminalNode)) { + throw new Error("Node provided is not a NonterminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's NonterminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} + +export function assertIsTerminalNode(node: unknown, kind?: TerminalKind, text?: string): asserts node is TerminalNode { + if (!(node instanceof TerminalNode)) { + throw new Error("Node provided is not a TerminalNode."); + } + + if (kind !== undefined && kind !== node.kind) { + throw new Error(`Node's TerminalKind is expected to be '${kind}', but got '${node.kind}'.`); + } + + if (text !== undefined && text !== node.unparse()) { + throw new Error(`Node's text content is expected to be '${text}', but got '${node.unparse()}'.`); + } +} diff --git a/crates/testlang/outputs/npm/package/src/generated/cst/index.ts b/crates/testlang/outputs/npm/package/src/generated/cst/index.ts deleted file mode 100644 index 7f845af258..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/cst/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -import * as generated from "../napi-bindings/generated"; - -export const NonterminalKind = generated.cst.NonterminalKind; -export type NonterminalKind = generated.cst.NonterminalKind; - -export const TerminalKind = generated.cst.TerminalKind; -export type TerminalKind = generated.cst.TerminalKind; - -export const EdgeLabel = generated.cst.EdgeLabel; -export type EdgeLabel = generated.cst.EdgeLabel; - -export type Node = generated.cst.Node; - -export const NodeType = generated.cst.NodeType; -export type NodeType = generated.cst.NodeType; - -export const NonterminalNode = generated.cst.NonterminalNode; -export type NonterminalNode = generated.cst.NonterminalNode; - -export const TerminalNode = generated.cst.TerminalNode; -export type TerminalNode = generated.cst.TerminalNode; - -export const Cursor = generated.cst.Cursor; -export type Cursor = generated.cst.Cursor; - -export const Query = generated.cst.Query; -export type Query = generated.cst.Query; - -export type QueryMatch = generated.cst.QueryMatch; - -export const QueryMatchIterator = generated.cst.QueryMatchIterator; -export type QueryMatchIterator = generated.cst.QueryMatchIterator; - -export type TextIndex = generated.cst.TextIndex; - -export type TextRange = generated.cst.TextRange; diff --git a/crates/testlang/outputs/npm/package/src/generated/diagnostic/index.ts b/crates/testlang/outputs/npm/package/src/generated/diagnostic/index.ts deleted file mode 100644 index 3de773e0d4..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/diagnostic/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -import * as generated from "../napi-bindings/generated"; - -export const Severity = generated.diagnostic.Severity; -export type Severity = generated.diagnostic.Severity; - -export const Diagnostic = generated.diagnostic.Diagnostic; -export type Diagnostic = generated.diagnostic.Diagnostic; - -// NOTE(#987): napi-rs does not allow us to either export traits as interfaces -// or interfaces with methods in general, so we define the interface ourselves. -export interface DiagnosticInterface { - textRange(): generated.cst.TextRange; - message(): string; - severity(): Severity; -} - -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; diff --git a/crates/testlang/outputs/npm/package/src/generated/index.mts b/crates/testlang/outputs/npm/package/src/generated/index.mts new file mode 100644 index 0000000000..847cd1d82b --- /dev/null +++ b/crates/testlang/outputs/npm/package/src/generated/index.mts @@ -0,0 +1,5 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export * as ast from "./ast/index.mjs"; +export * as cst from "./cst/index.mjs"; +export * as parser from "./parser/index.mjs"; diff --git a/crates/testlang/outputs/npm/package/src/generated/index.ts b/crates/testlang/outputs/npm/package/src/generated/index.ts deleted file mode 100644 index 7fb8ce0cac..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -export * as ast from "./ast"; -export * as cst from "./cst"; -export * as parser from "./parser"; diff --git a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts b/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts deleted file mode 100644 index aeaa69ccbd..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.d.ts +++ /dev/null @@ -1,190 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -export declare namespace cst { - export enum NonterminalKind { - AdditionExpression = "AdditionExpression", - Expression = "Expression", - Literal = "Literal", - MemberAccessExpression = "MemberAccessExpression", - NegationExpression = "NegationExpression", - SeparatedIdentifiers = "SeparatedIdentifiers", - SourceUnit = "SourceUnit", - SourceUnitMember = "SourceUnitMember", - SourceUnitMembers = "SourceUnitMembers", - Tree = "Tree", - TreeNode = "TreeNode", - TreeNodeChild = "TreeNodeChild", - TreeNodeChildren = "TreeNodeChildren", - } - export enum EdgeLabel { - Item = "Item", - Variant = "Variant", - Separator = "Separator", - Operand = "Operand", - LeftOperand = "LeftOperand", - RightOperand = "RightOperand", - LeadingTrivia = "LeadingTrivia", - TrailingTrivia = "TrailingTrivia", - CloseBracket = "CloseBracket", - Keyword = "Keyword", - Member = "Member", - Members = "Members", - Name = "Name", - Node = "Node", - OpenBracket = "OpenBracket", - Operator = "Operator", - Period = "Period", - Semicolon = "Semicolon", - } - export enum TerminalKind { - UNRECOGNIZED = "UNRECOGNIZED", - MISSING = "MISSING", - Bang = "Bang", - CloseBracket = "CloseBracket", - DelimitedIdentifier = "DelimitedIdentifier", - EndOfLine = "EndOfLine", - Identifier = "Identifier", - MultiLineComment = "MultiLineComment", - OpenBracket = "OpenBracket", - Period = "Period", - Plus = "Plus", - Semicolon = "Semicolon", - SingleLineComment = "SingleLineComment", - StringLiteral = "StringLiteral", - TreeKeyword = "TreeKeyword", - Whitespace = "Whitespace", - } - export enum NodeType { - Nonterminal = "Nonterminal", - Terminal = "Terminal", - } - export interface QueryMatch { - queryNumber: number; - captures: { [key: string]: cst.Cursor[] }; - } - export interface TextIndex { - utf8: number; - utf16: number; - line: number; - column: number; - } - export interface TextRange { - start: TextIndex; - end: TextIndex; - } - export class NonterminalNode { - get type(): cst.NodeType.Nonterminal; - get kind(): cst.NonterminalKind; - get textLength(): cst.TextIndex; - children(): Array; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - /** Serialize the node to JSON. */ - toJSON(): string; - unparse(): string; - } - export class TerminalNode { - get type(): cst.NodeType.Terminal; - get kind(): cst.TerminalKind; - get textLength(): cst.TextIndex; - get text(): string; - /** Serialize the node to JSON. */ - toJSON(): string; - createCursor(textOffset: cst.TextIndex): cst.Cursor; - } - export class Cursor { - reset(): void; - complete(): void; - clone(): Cursor; - spawn(): Cursor; - get isCompleted(): boolean; - node(): cst.Node; - get label(): cst.EdgeLabel; - get textOffset(): cst.TextIndex; - get textRange(): cst.TextRange; - get depth(): number; - ancestors(): Array; - goToNext(): boolean; - goToNextNonDescendent(): boolean; - goToPrevious(): boolean; - goToParent(): boolean; - goToFirstChild(): boolean; - goToLastChild(): boolean; - goToNthChild(childNumber: number): boolean; - goToNextSibling(): boolean; - goToPreviousSibling(): boolean; - goToNextTerminal(): boolean; - goToNextTerminalWithKind(kind: cst.TerminalKind): boolean; - goToNextTerminalWithKinds(kinds: Array): boolean; - goToNextNonterminal(): boolean; - goToNextNonterminalWithKind(kind: cst.NonterminalKind): boolean; - goToNextNonterminalWithKinds(kinds: Array): boolean; - query(queries: Array): cst.QueryMatchIterator; - } - export class Query { - static parse(text: string): Query; - } - export class QueryMatchIterator { - next(): QueryMatch | null; - } -} -export declare namespace parser { - export class Parser { - constructor(version: string); - get version(): string; - static supportedVersions(): Array; - static rootKind(): cst.NonterminalKind; - parse(kind: cst.NonterminalKind, input: string): parser.ParseOutput; - } - export class ParseError { - severity(): diagnostic.Severity; - textRange(): cst.TextRange; - message(): string; - } - export class ParseOutput { - tree(): cst.Node; - errors(): Array; - get isValid(): boolean; - /** Creates a cursor that starts at the root of the parse tree. */ - createTreeCursor(): cst.Cursor; - } -} -export declare namespace diagnostic { - /** - * Severity of the compiler diagnostic. - * - * Explicitly compatible with the LSP protocol. - */ - export enum Severity { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, - } - /** A compiler diagnostic that can be rendered to a user. */ - export class Diagnostic { - /** The severity of this diagnostic. */ - severity(): Severity; - /** The character range of the source that this diagnostic applies to. */ - textRange(): cst.TextRange; - /** The primary message associated with this diagnostic. */ - message(): string; - } -} -export declare namespace ast_internal { - export function selectSequence(node: cst.NonterminalNode): Array; - export function selectChoice(node: cst.NonterminalNode): cst.Node; - export function selectRepeated(node: cst.NonterminalNode): Array; - export function selectSeparated(node: cst.NonterminalNode): [Array, Array]; -} - -export namespace cst { - export type Node = TerminalNode | NonterminalNode; -} diff --git a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.js b/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.js deleted file mode 100644 index 6aaaa87660..0000000000 --- a/crates/testlang/outputs/npm/package/src/generated/napi-bindings/generated/index.js +++ /dev/null @@ -1,299 +0,0 @@ -// This file is generated automatically by infrastructure scripts. Please don't edit by hand. - -// Slang License: https://github.com/NomicFoundation/slang/blob/main/LICENSE -// NAPI-RS License: https://github.com/napi-rs/napi-rs/blob/main/LICENSE - -// @ts-nocheck - -/* tslint:disable */ -/* eslint-disable */ -/* prettier-ignore */ - -/* auto-generated by NAPI-RS */ - -const { existsSync, readFileSync } = require('fs') -const { join } = require("path"); - -const { platform, arch } = process; - -let nativeBinding = null; -let localFileExisted = false; -let loadError = null; - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== "function") { - try { - const lddPath = require("child_process").execSync("which ldd").toString().trim(); - return readFileSync(lddPath, "utf8").includes("musl"); - } catch (e) { - return true; - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header; - return !glibcVersionRuntime; - } -} - -switch (platform) { - case "android": - switch (arch) { - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.android-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm64.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-android-arm64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm": - localFileExisted = existsSync(join(__dirname, "index.android-arm-eabi.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.android-arm-eabi.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-android-arm-eabi"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Android ${arch}`); - } - break; - case "win32": - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.win32-x64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-x64-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-win32-x64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "ia32": - localFileExisted = existsSync(join(__dirname, "index.win32-ia32-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-ia32-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-win32-ia32-msvc"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.win32-arm64-msvc.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.win32-arm64-msvc.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-win32-arm64-msvc"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`); - } - break; - case "darwin": - localFileExisted = existsSync(join(__dirname, "index.darwin-universal.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-universal.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-darwin-universal"); - } - break; - } catch {} - switch (arch) { - case "x64": - localFileExisted = existsSync(join(__dirname, "index.darwin-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-x64.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-darwin-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "arm64": - localFileExisted = existsSync(join(__dirname, "index.darwin-arm64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.darwin-arm64.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-darwin-arm64"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`); - } - break; - case "freebsd": - if (arch !== "x64") { - throw new Error(`Unsupported architecture on FreeBSD: ${arch}`); - } - localFileExisted = existsSync(join(__dirname, "index.freebsd-x64.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.freebsd-x64.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-freebsd-x64"); - } - } catch (e) { - loadError = e; - } - break; - case "linux": - switch (arch) { - case "x64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-x64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-x64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-x64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-x64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-arm64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-arm64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "arm": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-musleabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-musleabihf.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-arm-musleabihf"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-arm-gnueabihf.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-arm-gnueabihf.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-arm-gnueabihf"); - } - } catch (e) { - loadError = e; - } - } - break; - case "riscv64": - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-musl.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-musl.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-riscv64-musl"); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, "index.linux-riscv64-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-riscv64-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-riscv64-gnu"); - } - } catch (e) { - loadError = e; - } - } - break; - case "s390x": - localFileExisted = existsSync(join(__dirname, "index.linux-s390x-gnu.node")); - try { - if (localFileExisted) { - nativeBinding = require("./index.linux-s390x-gnu.node"); - } else { - nativeBinding = require("@slang-private/slang-testlang-linux-s390x-gnu"); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`); - } - break; - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); -} - -if (!nativeBinding) { - if (loadError) { - throw loadError; - } - throw new Error(`Failed to load native binding`); -} - -const { cst, parser, diagnostic, ast_internal } = nativeBinding; - -module.exports.cst = cst; -module.exports.parser = parser; -module.exports.diagnostic = diagnostic; -module.exports.ast_internal = ast_internal; diff --git a/crates/solidity/outputs/npm/package/src/generated/parser/index.ts b/crates/testlang/outputs/npm/package/src/generated/parser/index.mts similarity index 62% rename from crates/solidity/outputs/npm/package/src/generated/parser/index.ts rename to crates/testlang/outputs/npm/package/src/generated/parser/index.mts index f3c36eefe6..14c315bbcd 100644 --- a/crates/solidity/outputs/npm/package/src/generated/parser/index.ts +++ b/crates/testlang/outputs/npm/package/src/generated/parser/index.mts @@ -1,7 +1,6 @@ // This file is generated automatically by infrastructure scripts. Please don't edit by hand. -import * as generated from "../napi-bindings/generated"; -import { DiagnosticInterface } from "../diagnostic"; +import * as generated from "../../../wasm/index.mjs"; export const Parser = generated.parser.Parser; export type Parser = generated.parser.Parser; @@ -9,8 +8,5 @@ export type Parser = generated.parser.Parser; export const ParseError = generated.parser.ParseError; export type ParseError = generated.parser.ParseError; -type AssertImplements = void; -declare const assertDiagnosticInterface: AssertImplements; - export const ParseOutput = generated.parser.ParseOutput; export type ParseOutput = generated.parser.ParseOutput; diff --git a/crates/testlang/outputs/npm/package/tsconfig.json b/crates/testlang/outputs/npm/package/tsconfig.json index 473e918c1d..7b4d9a1ad1 100644 --- a/crates/testlang/outputs/npm/package/tsconfig.json +++ b/crates/testlang/outputs/npm/package/tsconfig.json @@ -1,17 +1,9 @@ { "extends": "../../../../../tsconfig.json", - "include": ["./src/**/*.ts"], + "include": ["./**/*"], "compilerOptions": { - /* Modules */ - "module": "CommonJS", - "moduleResolution": "Node", - "rootDir": "./src/generated", - - /* Language and Environment */ - "target": "ES2016", - /* Projects */ "composite": true, "incremental": true, diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts new file mode 100644 index 0000000000..138e7f7f89 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-ast.d.ts @@ -0,0 +1,16 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangAst { + export { Selectors }; +} +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalNode } from "./nomic-foundation-slang-cst.js"; +export { NonterminalNode }; + +export class Selectors { + static sequence(node: NonterminalNode): (Node | undefined)[]; + static choice(node: NonterminalNode): Node; + static repeated(node: NonterminalNode): Node[]; + static separated(node: NonterminalNode): Node[][]; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts new file mode 100644 index 0000000000..4e1546618c --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-cst.d.ts @@ -0,0 +1,175 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangCst { + export { TerminalKindExtensions }; + export { NonterminalNode }; + export { TerminalNode }; + export { Cursor }; + export { Query }; + export { QueryMatchIterator }; + export { NonterminalKind }; + export { TerminalKind }; + export { EdgeLabel }; + export { Node }; + export { NodeVariant }; +} +export declare enum NonterminalKind { + AdditionExpression = "AdditionExpression", + Expression = "Expression", + Literal = "Literal", + MemberAccessExpression = "MemberAccessExpression", + NegationExpression = "NegationExpression", + SeparatedIdentifiers = "SeparatedIdentifiers", + SourceUnit = "SourceUnit", + SourceUnitMember = "SourceUnitMember", + SourceUnitMembers = "SourceUnitMembers", + Tree = "Tree", + TreeNode = "TreeNode", + TreeNodeChild = "TreeNodeChild", + TreeNodeChildren = "TreeNodeChildren", +} +export declare enum TerminalKind { + Unrecognized = "Unrecognized", + Missing = "Missing", + Bang = "Bang", + CloseBracket = "CloseBracket", + DelimitedIdentifier = "DelimitedIdentifier", + EndOfLine = "EndOfLine", + Identifier = "Identifier", + MultiLineComment = "MultiLineComment", + OpenBracket = "OpenBracket", + Period = "Period", + Plus = "Plus", + Semicolon = "Semicolon", + SingleLineComment = "SingleLineComment", + StringLiteral = "StringLiteral", + TreeKeyword = "TreeKeyword", + Whitespace = "Whitespace", +} +export declare enum EdgeLabel { + Item = "Item", + Variant = "Variant", + Separator = "Separator", + Operand = "Operand", + LeftOperand = "LeftOperand", + RightOperand = "RightOperand", + LeadingTrivia = "LeadingTrivia", + TrailingTrivia = "TrailingTrivia", + CloseBracket = "CloseBracket", + Keyword = "Keyword", + Member = "Member", + Members = "Members", + Name = "Name", + Node = "Node", + OpenBracket = "OpenBracket", + Operator = "Operator", + Period = "Period", + Semicolon = "Semicolon", +} +export type Node = NonterminalNode | TerminalNode; +export enum NodeVariant { + NonterminalNode = "NonterminalNode", + TerminalNode = "TerminalNode", +} +export interface Edge { + label?: EdgeLabel; + node: Node; +} +export interface QueryError { + message: string; + line: number; + column: number; +} +export interface QueryMatch { + queryNumber: number; + captures: { [key: string]: Cursor[] }; +} +export interface TextIndex { + utf8: number; + utf16: number; + line: number; + column: number; +} +export interface TextRange { + start: TextIndex; + end: TextIndex; +} + +export class Cursor { + reset(): void; + complete(): void; + isCompleted(): boolean; + clone(): Cursor; + spawn(): Cursor; + get node(): Node; + get label(): EdgeLabel | undefined; + get textOffset(): TextIndex; + get textRange(): TextRange; + get depth(): number; + get ancestors(): NonterminalNode[]; + goToNext(): boolean; + goToNextNonDescendent(): boolean; + goToPrevious(): boolean; + goToParent(): boolean; + goToFirstChild(): boolean; + goToLastChild(): boolean; + goToNthChild(childNumber: number): boolean; + goToNextSibling(): boolean; + goToPreviousSibling(): boolean; + goToNextTerminal(): boolean; + goToNextTerminalWithKind(kind: TerminalKind): boolean; + goToNextTerminalWithKinds(kinds: TerminalKind[]): boolean; + goToNextNonterminal(): boolean; + goToNextNonterminalWithKind(kind: NonterminalKind): boolean; + goToNextNonterminalWithKinds(kinds: NonterminalKind[]): boolean; + query(queries: Query[]): QueryMatchIterator; +} + +export class NonterminalNode { + readonly nodeVariant = NodeVariant.NonterminalNode; + + asNonterminalNode(): this; + isNonterminalNode(): this is NonterminalNode; + + asTerminalNode(): undefined; + isTerminalNode(): false; + + get id(): number; + get kind(): NonterminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; + createCursor(textOffset: TextIndex): Cursor; +} + +export class Query { + static parse(text: string): Query; +} + +export class QueryMatchIterator { + [Symbol.iterator](): Iterator; + next(): QueryMatch | undefined; +} + +export class TerminalKindExtensions { + static isTrivia(kind: TerminalKind): boolean; + static isValid(kind: TerminalKind): boolean; +} + +export class TerminalNode { + readonly nodeVariant = NodeVariant.TerminalNode; + + asTerminalNode(): this; + isTerminalNode(): this is TerminalNode; + + asNonterminalNode(): undefined; + isNonterminalNode(): false; + + get id(): number; + get kind(): TerminalKind; + get textLength(): TextIndex; + get children(): Edge[]; + unparse(): string; + toJson(): string; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts new file mode 100644 index 0000000000..c759bea9a5 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/nomic-foundation-slang-parser.d.ts @@ -0,0 +1,35 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace NomicFoundationSlangParser { + export { Parser }; + export { ParseError }; + export { ParseOutput }; +} +import type { Cursor } from "./nomic-foundation-slang-cst.js"; +export { Cursor }; +import type { Node } from "./nomic-foundation-slang-cst.js"; +export { Node }; +import type { NonterminalKind } from "./nomic-foundation-slang-cst.js"; +export { NonterminalKind }; +import type { TextRange } from "./nomic-foundation-slang-cst.js"; +export { TextRange }; + +export class ParseError { + get textRange(): TextRange; + get message(): string; +} + +export class ParseOutput { + get tree(): Node; + get errors(): ParseError[]; + isValid(): boolean; + createTreeCursor(): Cursor; +} + +export class Parser { + static rootKind(): NonterminalKind; + static supportedVersions(): string[]; + static create(version: string): Parser; + get version(): string; + parse(kind: NonterminalKind, input: string): ParseOutput; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts new file mode 100644 index 0000000000..2e7e18e20c --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-environment.d.ts @@ -0,0 +1,5 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliEnvironment { + export function getEnvironment(): [string, string][]; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts new file mode 100644 index 0000000000..00e416f2a9 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-exit.d.ts @@ -0,0 +1,6 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliExit { + export function exit(status: Result): void; +} +export type Result = { tag: "ok"; val: T } | { tag: "err"; val: E }; diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts new file mode 100644 index 0000000000..58b90e29bf --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stderr.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStderr { + export function getStderr(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts new file mode 100644 index 0000000000..e5f574f5bd --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdin.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdin { + export function getStdin(): InputStream; +} +import type { InputStream } from "./wasi-io-streams.js"; +export { InputStream }; diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts new file mode 100644 index 0000000000..49023013c5 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-cli-stdout.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiCliStdout { + export function getStdout(): OutputStream; +} +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts new file mode 100644 index 0000000000..ea190faee8 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiClocksWallClock {} +export interface Datetime { + seconds: bigint; + nanoseconds: number; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts new file mode 100644 index 0000000000..7c94c88da2 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemPreopens { + export function getDirectories(): [Descriptor, string][]; +} +import type { Descriptor } from "./wasi-filesystem-types.js"; +export { Descriptor }; diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts new file mode 100644 index 0000000000..140b5f4bac --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-filesystem-types.d.ts @@ -0,0 +1,172 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiFilesystemTypes { + export { Descriptor }; + export function filesystemErrorCode(err: Error): ErrorCode | undefined; +} +export type Filesize = bigint; +import type { OutputStream } from "./wasi-io-streams.js"; +export { OutputStream }; +/** + * # Variants + * + * ## `"access"` + * + * ## `"would-block"` + * + * ## `"already"` + * + * ## `"bad-descriptor"` + * + * ## `"busy"` + * + * ## `"deadlock"` + * + * ## `"quota"` + * + * ## `"exist"` + * + * ## `"file-too-large"` + * + * ## `"illegal-byte-sequence"` + * + * ## `"in-progress"` + * + * ## `"interrupted"` + * + * ## `"invalid"` + * + * ## `"io"` + * + * ## `"is-directory"` + * + * ## `"loop"` + * + * ## `"too-many-links"` + * + * ## `"message-size"` + * + * ## `"name-too-long"` + * + * ## `"no-device"` + * + * ## `"no-entry"` + * + * ## `"no-lock"` + * + * ## `"insufficient-memory"` + * + * ## `"insufficient-space"` + * + * ## `"not-directory"` + * + * ## `"not-empty"` + * + * ## `"not-recoverable"` + * + * ## `"unsupported"` + * + * ## `"no-tty"` + * + * ## `"no-such-device"` + * + * ## `"overflow"` + * + * ## `"not-permitted"` + * + * ## `"pipe"` + * + * ## `"read-only"` + * + * ## `"invalid-seek"` + * + * ## `"text-file-busy"` + * + * ## `"cross-device"` + */ +export type ErrorCode = + | "access" + | "would-block" + | "already" + | "bad-descriptor" + | "busy" + | "deadlock" + | "quota" + | "exist" + | "file-too-large" + | "illegal-byte-sequence" + | "in-progress" + | "interrupted" + | "invalid" + | "io" + | "is-directory" + | "loop" + | "too-many-links" + | "message-size" + | "name-too-long" + | "no-device" + | "no-entry" + | "no-lock" + | "insufficient-memory" + | "insufficient-space" + | "not-directory" + | "not-empty" + | "not-recoverable" + | "unsupported" + | "no-tty" + | "no-such-device" + | "overflow" + | "not-permitted" + | "pipe" + | "read-only" + | "invalid-seek" + | "text-file-busy" + | "cross-device"; +/** + * # Variants + * + * ## `"unknown"` + * + * ## `"block-device"` + * + * ## `"character-device"` + * + * ## `"directory"` + * + * ## `"fifo"` + * + * ## `"symbolic-link"` + * + * ## `"regular-file"` + * + * ## `"socket"` + */ +export type DescriptorType = + | "unknown" + | "block-device" + | "character-device" + | "directory" + | "fifo" + | "symbolic-link" + | "regular-file" + | "socket"; +export type LinkCount = bigint; +import type { Datetime } from "./wasi-clocks-wall-clock.js"; +export { Datetime }; +export interface DescriptorStat { + type: DescriptorType; + linkCount: LinkCount; + size: Filesize; + dataAccessTimestamp?: Datetime; + dataModificationTimestamp?: Datetime; + statusChangeTimestamp?: Datetime; +} +import type { Error } from "./wasi-io-streams.js"; +export { Error }; + +export class Descriptor { + writeViaStream(offset: Filesize): OutputStream; + appendViaStream(): OutputStream; + getType(): DescriptorType; + stat(): DescriptorStat; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts new file mode 100644 index 0000000000..f52a8b4cc5 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-error.d.ts @@ -0,0 +1,7 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiIoError { + export { Error }; +} + +export class Error {} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts new file mode 100644 index 0000000000..fc56e10c39 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/interfaces/wasi-io-streams.d.ts @@ -0,0 +1,25 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +export namespace WasiIoStreams { + export { OutputStream }; + export { InputStream }; +} +import type { Error } from "./wasi-io-error.js"; +export { Error }; +export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed; +export interface StreamErrorLastOperationFailed { + tag: "last-operation-failed"; + val: Error; +} +export interface StreamErrorClosed { + tag: "closed"; +} + +export class InputStream {} + +export class OutputStream { + checkWrite(): bigint; + write(contents: Uint8Array): void; + blockingWriteAndFlush(contents: Uint8Array): void; + blockingFlush(): void; +} diff --git a/crates/testlang/outputs/npm/package/wasm/generated/testlang_cargo_wasm.component.d.ts b/crates/testlang/outputs/npm/package/wasm/generated/testlang_cargo_wasm.component.d.ts new file mode 100644 index 0000000000..237bb59193 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/generated/testlang_cargo_wasm.component.d.ts @@ -0,0 +1,18 @@ +// This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +import { WasiCliEnvironment } from "./interfaces/wasi-cli-environment.js"; +import { WasiCliExit } from "./interfaces/wasi-cli-exit.js"; +import { WasiCliStderr } from "./interfaces/wasi-cli-stderr.js"; +import { WasiCliStdin } from "./interfaces/wasi-cli-stdin.js"; +import { WasiCliStdout } from "./interfaces/wasi-cli-stdout.js"; +import { WasiClocksWallClock } from "./interfaces/wasi-clocks-wall-clock.js"; +import { WasiFilesystemPreopens } from "./interfaces/wasi-filesystem-preopens.js"; +import { WasiFilesystemTypes } from "./interfaces/wasi-filesystem-types.js"; +import { WasiIoError } from "./interfaces/wasi-io-error.js"; +import { WasiIoStreams } from "./interfaces/wasi-io-streams.js"; +import { NomicFoundationSlangCst } from "./interfaces/nomic-foundation-slang-cst.js"; +import { NomicFoundationSlangAst } from "./interfaces/nomic-foundation-slang-ast.js"; +import { NomicFoundationSlangParser } from "./interfaces/nomic-foundation-slang-parser.js"; +export * as cst from "./interfaces/nomic-foundation-slang-cst.js"; +export * as ast from "./interfaces/nomic-foundation-slang-ast.js"; +export * as parser from "./interfaces/nomic-foundation-slang-parser.js"; diff --git a/crates/testlang/outputs/npm/package/wasm/index.mts b/crates/testlang/outputs/npm/package/wasm/index.mts new file mode 100644 index 0000000000..6830c2d472 --- /dev/null +++ b/crates/testlang/outputs/npm/package/wasm/index.mts @@ -0,0 +1 @@ +export * from "./generated/testlang_cargo_wasm.component.js"; diff --git a/crates/testlang/outputs/npm/tests/jest.config.ts b/crates/testlang/outputs/npm/tests/jest.config.ts index d539a9e714..8cd86e9f39 100644 --- a/crates/testlang/outputs/npm/tests/jest.config.ts +++ b/crates/testlang/outputs/npm/tests/jest.config.ts @@ -1,17 +1,11 @@ import type { Config } from "jest"; const config: Config = { - rootDir: __dirname, - testMatch: ["/src/tests/**/*.ts"], + testMatch: ["/src/tests/**/*.mts"], - moduleNameMapper: { - // __SLANG_NPM_PACKAGE_MAIN_OUTPUT_DIR__ (keep in sync) - "^@slang-private/slang-testlang$": "/../package/target/npm/main", - "^@slang-private/slang-testlang/(.*)?$": "/../package/target/npm/main/$1", - }, - - testEnvironment: "node", - preset: "ts-jest", + preset: "ts-jest/presets/default-esm", + resolver: "ts-jest-resolver", + moduleFileExtensions: ["js", "mjs", "cjs", "jsx", "ts", "mts", "cts", "tsx", "json", "node"], cacheDirectory: "/target/jest/cache", slowTestThreshold: 5, diff --git a/crates/testlang/outputs/npm/tests/package.json b/crates/testlang/outputs/npm/tests/package.json index 9ba3051de2..e13d5f10c5 100644 --- a/crates/testlang/outputs/npm/tests/package.json +++ b/crates/testlang/outputs/npm/tests/package.json @@ -1,10 +1,15 @@ { "name": "@slang-private/testlang-npm-tests", "private": true, + "type": "module", + "dependencies": { + "@slang-private/testlang-npm-package": "file:../package" + }, "devDependencies": { "@types/jest": "29.5.13", "jest": "29.7.0", "ts-jest": "29.2.5", + "ts-jest-resolver": "2.0.1", "ts-node": "10.9.2" } } diff --git a/crates/testlang/outputs/npm/tests/src/tests/ast.ts b/crates/testlang/outputs/npm/tests/src/tests/ast.ts deleted file mode 100644 index d07dc15ec5..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/ast.ts +++ /dev/null @@ -1,196 +0,0 @@ -import assert from "node:assert"; -import { Parser } from "@slang-private/slang-testlang/parser"; -import { - AdditionExpression, - Expression, - MemberAccessExpression, - NegationExpression, - SeparatedIdentifiers, - SourceUnit, - Tree, - TreeNode, - TreeNodeChild, -} from "@slang-private/slang-testlang/ast"; -import { expectNonterminal, expectTerminal } from "../utils/cst-helpers"; -import { NonterminalKind, TerminalKind, TerminalNode } from "@slang-private/slang-testlang/cst"; - -test("create and use sequence types", () => { - const source = `tree [A B C];`.trim(); - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Tree, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Tree); - - const tree = new Tree(cst); - expectNonterminal(tree.cst, NonterminalKind.Tree); - expect(tree.name).toBeUndefined(); - expect(tree.node.members.items).toHaveLength(3); -}); - -test("create and use choice types", () => { - const source = `[B]`.trim(); - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.TreeNodeChild, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.TreeNodeChild); - - const tree_node_child = new TreeNodeChild(cst); - expectNonterminal(tree_node_child.cst, NonterminalKind.TreeNodeChild); - expect(tree_node_child.variant).toBeInstanceOf(TreeNode); - - const tree_node = tree_node_child.variant as TreeNode; - expectNonterminal(tree_node.cst, NonterminalKind.TreeNode); - expectNonterminal(tree_node.members.cst, NonterminalKind.TreeNodeChildren); - expectTerminal(tree_node.openBracket, TerminalKind.OpenBracket, "["); - expectTerminal(tree_node.closeBracket, TerminalKind.CloseBracket, "]"); -}); - -test("create and use repeated types", () => { - const source = `tree [A B C];`.trim(); - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Tree, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Tree); - - const tree = new Tree(cst); - expectNonterminal(tree.node.members.cst, NonterminalKind.TreeNodeChildren); - - const names = tree.node.members.items.map((item) => { - expect(item.variant).toBeInstanceOf(TerminalNode); - - return (item.variant as TerminalNode).text; - }); - - expect(names).toStrictEqual(["A", "B", "C"]); -}); - -test("create and use separated types", () => { - const source = `Foo.Bar.Baz`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.SeparatedIdentifiers, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.SeparatedIdentifiers); - - const separated_identifiers = new SeparatedIdentifiers(cst); - expectNonterminal(separated_identifiers.cst, NonterminalKind.SeparatedIdentifiers); - - const identifiers = separated_identifiers.items.map((identifier) => identifier.text); - expect(identifiers).toStrictEqual(["Foo", "Bar", "Baz"]); - - const periods = separated_identifiers.separators.map((separator) => separator.text); - expect(periods).toStrictEqual([".", "."]); -}); - -test("throws an exception on initializing the wrong type", () => { - const source = `tree [A];`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Tree, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Tree); - - expect(() => new SourceUnit(cst)).toThrow("SourceUnit can only be initialized with a CST node of the same kind."); -}); - -test("throws an exception on on using an incorrect/incomplete CST node", () => { - const source = `tree`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Tree, source); - expect(parseOutput.errors()).toHaveLength(1); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Tree); - expect(cst.children()).toHaveLength(2); - - const [contractKeyword, skippedTerminal] = cst.children(); - expectTerminal(contractKeyword, TerminalKind.TreeKeyword, "tree"); - expectTerminal(skippedTerminal, TerminalKind.MISSING, ""); - - // Creating the tree should succeed, as the fields are lazily intialized. - const tree = new Tree(cst); - expectNonterminal(tree.cst, NonterminalKind.Tree); - - expect(() => tree.node).toThrow( - "Missing child with label 'node'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.", - ); -}); - -test("create and use prefix expressions", () => { - const source = `!foo`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Expression, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Expression); - - const expression = new Expression(cst); - assert(expression.variant instanceof NegationExpression); - - const { operator, operand } = expression.variant; - expectTerminal(operator, TerminalKind.Bang, "!"); - expectTerminal(operand.variant, TerminalKind.Identifier, "foo"); -}); - -test("create and use postfix expressions", () => { - const source = `foo.bar`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Expression, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Expression); - - const expression = new Expression(cst); - assert(expression.variant instanceof MemberAccessExpression); - - const { operand, period, member } = expression.variant; - expectTerminal(operand.variant, TerminalKind.Identifier, "foo"); - expectTerminal(period, TerminalKind.Period, "."); - expectTerminal(member, TerminalKind.Identifier, "bar"); -}); - -test("create and use binary expressions", () => { - const source = `foo + bar`; - - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.Expression, source); - expect(parseOutput.errors()).toHaveLength(0); - - const cst = parseOutput.tree(); - expectNonterminal(cst, NonterminalKind.Expression); - - const expression = new Expression(cst); - assert(expression.variant instanceof AdditionExpression); - - const { leftOperand, operator, rightOperand } = expression.variant; - expectTerminal(leftOperand.variant, TerminalKind.Identifier, "foo"); - expectTerminal(operator, TerminalKind.Plus, "+"); - expectTerminal(rightOperand.variant, TerminalKind.Identifier, "bar"); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/ast/ast.mts b/crates/testlang/outputs/npm/tests/src/tests/ast/ast.mts new file mode 100644 index 0000000000..e85b9e0450 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/ast/ast.mts @@ -0,0 +1,203 @@ +import assert from "node:assert"; +import { Parser } from "@slang-private/testlang-npm-package/parser"; +import { + AdditionExpression, + Expression, + MemberAccessExpression, + NegationExpression, + SeparatedIdentifiers, + SourceUnit, + Tree, + TreeNode, + TreeNodeChild, +} from "@slang-private/testlang-npm-package/ast"; +import { + assertIsNonterminalNode, + assertIsTerminalNode, + NonterminalKind, + TerminalKind, +} from "@slang-private/testlang-npm-package/cst"; + +test("create and use sequence types", () => { + const source = `tree [A B C];`.trim(); + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Tree, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Tree); + + const ast = new Tree(cst); + expect(ast.keyword.unparse()).toEqual("tree"); + expect(ast.name).toBeUndefined(); + expect(ast.node.members.items).toHaveLength(3); + expect(ast.semicolon.unparse()).toEqual(";"); +}); + +test("create and use choice types", () => { + const source = `[B]`.trim(); + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.TreeNodeChild, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.TreeNodeChild); + + const treeNodeChild = new TreeNodeChild(cst); + assertIsNonterminalNode(treeNodeChild.cst, NonterminalKind.TreeNodeChild); + expect(treeNodeChild.variant).toBeInstanceOf(TreeNode); + + const treeNode = treeNodeChild.variant as TreeNode; + assertIsNonterminalNode(treeNode.cst, NonterminalKind.TreeNode); + assertIsNonterminalNode(treeNode.members.cst, NonterminalKind.TreeNodeChildren); + assertIsTerminalNode(treeNode.openBracket, TerminalKind.OpenBracket, "["); + assertIsTerminalNode(treeNode.closeBracket, TerminalKind.CloseBracket, "]"); +}); + +test("create and use repeated types", () => { + const source = `tree [A B C];`.trim(); + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Tree, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Tree); + + const tree = new Tree(cst); + assertIsNonterminalNode(tree.node.members.cst, NonterminalKind.TreeNodeChildren); + + const names = tree.node.members.items.map((item) => { + assertIsTerminalNode(item.variant); + return item.variant.unparse(); + }); + + expect(names).toStrictEqual(["A", "B", "C"]); +}); + +test("create and use separated types", () => { + const source = `Foo.Bar.Baz`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.SeparatedIdentifiers, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.SeparatedIdentifiers); + + const separatedIdentifiers = new SeparatedIdentifiers(cst); + assertIsNonterminalNode(separatedIdentifiers.cst, NonterminalKind.SeparatedIdentifiers); + + const identifiers = separatedIdentifiers.items.map((identifier) => identifier.unparse()); + expect(identifiers).toStrictEqual(["Foo", "Bar", "Baz"]); + + const periods = separatedIdentifiers.separators.map((separator) => separator.unparse()); + expect(periods).toStrictEqual([".", "."]); +}); + +test("throws an exception on initializing the wrong type", () => { + const source = `tree [A];`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Tree, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Tree); + + expect(() => new SourceUnit(cst)).toThrow( + "AST node 'SourceUnit' can only be initialized with a CST node of the same kind. Received 'Tree' instead.", + ); +}); + +test("throws an exception on on using an incorrect/incomplete CST node", () => { + const source = `tree`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Tree, source); + expect(parseOutput.isValid()).toBeFalsy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Tree); + + expect(cst.children).toHaveLength(2); + + const [contractKeyword, skippedTerminal] = cst.children; + assertIsTerminalNode(contractKeyword!.node, TerminalKind.TreeKeyword, "tree"); + assertIsTerminalNode(skippedTerminal!.node, TerminalKind.Missing, ""); + + // Creating the tree should succeed, as the fields are lazily intialized. + const tree = new Tree(cst); + assertIsNonterminalNode(tree.cst, NonterminalKind.Tree); + + expect(() => tree.node).toThrow( + "Missing child with label 'node'. Creating AST types from incorrect/incomplete CST nodes is not supported yet.", + ); +}); + +test("create and use prefix expressions", () => { + const source = `!foo`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Expression, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Expression); + + const expression = new Expression(cst); + assert(expression.variant instanceof NegationExpression); + + const { operator, operand } = expression.variant; + assertIsTerminalNode(operator, TerminalKind.Bang, "!"); + assertIsTerminalNode(operand.variant, TerminalKind.Identifier, "foo"); +}); + +test("create and use postfix expressions", () => { + const source = `foo.bar`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Expression, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Expression); + + const expression = new Expression(cst); + assert(expression.variant instanceof MemberAccessExpression); + + const { operand, period, member } = expression.variant; + assertIsTerminalNode(operand.variant, TerminalKind.Identifier, "foo"); + assertIsTerminalNode(period, TerminalKind.Period, "."); + assertIsTerminalNode(member, TerminalKind.Identifier, "bar"); +}); + +test("create and use binary expressions", () => { + const source = `foo + bar`; + + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.Expression, source); + expect(parseOutput.isValid()).toBeTruthy(); + + const cst = parseOutput.tree; + assertIsNonterminalNode(cst, NonterminalKind.Expression); + + const expression = new Expression(cst); + assert(expression.variant instanceof AdditionExpression); + + const { leftOperand, operator, rightOperand } = expression.variant; + assertIsTerminalNode(leftOperand.variant, TerminalKind.Identifier, "foo"); + assertIsTerminalNode(operator, TerminalKind.Plus, "+"); + assertIsTerminalNode(rightOperand.variant, TerminalKind.Identifier, "bar"); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts b/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts deleted file mode 100644 index c4a021e8a1..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-cursor.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { Parser } from "@slang-private/slang-testlang/parser"; -import { expectNonterminal, expectTerminal } from "../utils/cst-helpers"; -import { Cursor, EdgeLabel, NodeType, NonterminalKind, TerminalKind } from "@slang-private/slang-testlang/cst"; - -test("use cursor", () => { - const source = "tree [A [B C] D];"; - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.SourceUnit, source); - const cursor: Cursor = parseOutput.createTreeCursor(); - - expectNonterminal(cursor.node(), NonterminalKind.SourceUnit); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.SourceUnitMembers); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.SourceUnitMember); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.Tree); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.TreeKeyword, "tree"); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNode); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChildren); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "A"); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNode); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.OpenBracket, "["); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChildren); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "B"); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "C"); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.CloseBracket, "]"); - expect(cursor.goToNext()).toBe(true); - - expectNonterminal(cursor.node(), NonterminalKind.TreeNodeChild); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.Whitespace, " "); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.DelimitedIdentifier, "D"); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.CloseBracket, "]"); - expect(cursor.goToNext()).toBe(true); - - expectTerminal(cursor.node(), TerminalKind.Semicolon, ";"); - expect(cursor.goToNext()).toBe(false); -}); - -test("access the node using its name", () => { - const source = "tree [A [B C] D];"; - const parser = new Parser("1.0.0"); - const parseTree = parser.parse(NonterminalKind.SourceUnit, source); - - const cursor = parseTree.createTreeCursor(); - let names: string[] = []; - - while (cursor.goToNextNonterminalWithKind(NonterminalKind.TreeNode)) { - const innerCursor = cursor.spawn(); - while (innerCursor.goToNext()) { - const node = innerCursor.node(); - const label = innerCursor.label; - - if (node.type == NodeType.Terminal && (label == EdgeLabel.OpenBracket || label == EdgeLabel.CloseBracket)) { - names.push(node.text); - } - } - } - - expect(names).toEqual(["[", "[", "]", "]", "[", "]"]); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts b/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts deleted file mode 100644 index bab0bad74a..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/cst-output.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { Parser } from "@slang-private/slang-testlang/parser"; -import { NonterminalKind, TerminalKind } from "@slang-private/slang-testlang/cst"; -import { expectNonterminal, expectTerminal } from "../utils/cst-helpers"; - -test("parse terminal", () => { - const source = "About_time"; - const parser = new Parser("1.0.0"); - - const parseTree = parser.parse(NonterminalKind.TreeNodeChild, source).tree(); - expectNonterminal(parseTree, NonterminalKind.TreeNodeChild); - - const children = parseTree.children(); - expect(children).toHaveLength(1); - - expectTerminal(children[0]!, TerminalKind.DelimitedIdentifier, "About_time"); -}); - -test("parse nonterminal", () => { - const source = `tree [A [B C] D];`; - const parser = new Parser("1.0.0"); - - const parseTree = parser.parse(NonterminalKind.SourceUnit, source).tree(); - expectNonterminal(parseTree, NonterminalKind.SourceUnit); - - const children = parseTree.children(); - expect(children).toHaveLength(1); - - expectNonterminal(children[0]!, NonterminalKind.SourceUnitMembers); -}); - -test("trivial cursor access", () => { - const source = `tree [A [B C] D];`; - const parser = new Parser("1.0.0"); - - const parseOutput = parser.parse(NonterminalKind.SourceUnit, source); - const node = parseOutput.createTreeCursor().node(); - expectNonterminal(node, NonterminalKind.SourceUnit); - - const children = node.children(); - expect(children).toHaveLength(1); -}); - -test("calculate unicode characters text length", () => { - const source = `"some 😁 emoji"`; - const parser = new Parser("1.0.0"); - - const parseTree = parser.parse(NonterminalKind.Literal, source).tree(); - expectNonterminal(parseTree, NonterminalKind.Literal); - - expect(parseTree.textLength).toEqual({ - line: 0, - column: 14, - utf16: 15, - utf8: 17, - }); - - const children = parseTree.children(); - expect(children).toHaveLength(1); - - const terminal = children[0]!; - expectTerminal(terminal, TerminalKind.StringLiteral, `"some 😁 emoji"`); - expect(terminal.textLength).toEqual({ - line: 0, - column: 14, - utf16: 15, - utf8: 17, - }); -}); - -test("can unparse nonterminal nodes", () => { - const source = `tree [A [B C] D];`; - const parser = new Parser("1.0.0"); - - const parseTree = parser.parse(NonterminalKind.SourceUnit, source).tree(); - expectNonterminal(parseTree, NonterminalKind.SourceUnit); - - expect(parseTree.unparse()).toEqual(source); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst/cursor.mts b/crates/testlang/outputs/npm/tests/src/tests/cst/cursor.mts new file mode 100644 index 0000000000..2a69cfb088 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/cst/cursor.mts @@ -0,0 +1,125 @@ +import { Parser } from "@slang-private/testlang-npm-package/parser"; +import { + Cursor, + EdgeLabel, + NodeVariant, + assertIsNonterminalNode, + assertIsTerminalNode, + NonterminalKind, + TerminalKind, +} from "@slang-private/testlang-npm-package/cst"; + +test("use cursor goToNext()", () => { + const source = "tree [A [B C] D];"; + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.SourceUnit, source); + const cursor: Cursor = parseOutput.createTreeCursor(); + + assertIsNonterminalNode(cursor.node, NonterminalKind.SourceUnit); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.SourceUnitMembers); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.SourceUnitMember); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.Tree); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.TreeKeyword, "tree"); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNode); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.Whitespace, " "); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.OpenBracket, "["); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChildren); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChild); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.DelimitedIdentifier, "A"); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChild); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNode); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.Whitespace, " "); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.OpenBracket, "["); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChildren); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChild); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.DelimitedIdentifier, "B"); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChild); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.Whitespace, " "); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.DelimitedIdentifier, "C"); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.CloseBracket, "]"); + expect(cursor.goToNext()).toBe(true); + + assertIsNonterminalNode(cursor.node, NonterminalKind.TreeNodeChild); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.Whitespace, " "); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.DelimitedIdentifier, "D"); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.CloseBracket, "]"); + expect(cursor.goToNext()).toBe(true); + + assertIsTerminalNode(cursor.node, TerminalKind.Semicolon, ";"); + expect(cursor.goToNext()).toBe(false); +}); + +test("access the node using its name", () => { + const source = "tree [A [B C] D];"; + const parser = Parser.create("1.0.0"); + const parseTree = parser.parse(NonterminalKind.SourceUnit, source); + + const cursor = parseTree.createTreeCursor(); + let names: string[] = []; + + while (cursor.goToNextNonterminalWithKind(NonterminalKind.TreeNode)) { + const innerCursor = cursor.spawn(); + while (innerCursor.goToNext()) { + const node = innerCursor.node; + const label = innerCursor.label; + + if ( + node.nodeVariant == NodeVariant.TerminalNode && + (label == EdgeLabel.OpenBracket || label == EdgeLabel.CloseBracket) + ) { + names.push(node.unparse()); + } + } + } + + expect(names).toEqual(["[", "[", "]", "]", "[", "]"]); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst/nodes.mts b/crates/testlang/outputs/npm/tests/src/tests/cst/nodes.mts new file mode 100644 index 0000000000..0197bdcb62 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/cst/nodes.mts @@ -0,0 +1,53 @@ +import { Parser } from "@slang-private/testlang-npm-package/parser"; +import { + EdgeLabel, + NonterminalKind, + TerminalKind, + assertIsNonterminalNode, + assertIsTerminalNode, +} from "@slang-private/testlang-npm-package/cst"; + +describe("nodes", () => { + const source = `"foo"`; + const parseOutput = Parser.create("1.0.0").parse(NonterminalKind.Literal, source); + + const nonTerminal = parseOutput.tree; + assertIsNonterminalNode(nonTerminal, NonterminalKind.Literal); + + describe("NonTerminal", () => { + it("unparse()", () => { + expect(nonTerminal.unparse()).toEqual(source); + }); + + it("toJson()", () => { + expect(JSON.parse(nonTerminal.toJson())).toEqual({ + kind: NonterminalKind.Literal, + children: [ + { + label: EdgeLabel.Variant, + node: { + kind: TerminalKind.StringLiteral, + text: source, + }, + }, + ], + }); + }); + }); + + const terminal = nonTerminal.children[0]!.node; + assertIsTerminalNode(terminal, TerminalKind.StringLiteral); + + describe("Terminal", () => { + it("unparse()", () => { + expect(terminal.unparse()).toEqual(source); + }); + + it("toJson()", () => { + expect(JSON.parse(terminal.toJson())).toEqual({ + kind: TerminalKind.StringLiteral, + text: source, + }); + }); + }); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst/query.mts b/crates/testlang/outputs/npm/tests/src/tests/cst/query.mts new file mode 100644 index 0000000000..4aee305a0e --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/cst/query.mts @@ -0,0 +1,56 @@ +import { + NonterminalKind, + TerminalKind, + Query, + assertIsTerminalNode, + QueryError, +} from "@slang-private/testlang-npm-package/cst"; +import { Parser } from "@slang-private/testlang-npm-package/parser"; + +test("simple query", () => { + const parser = Parser.create("1.0.0"); + const treeSource = `tree [A [B C] D];`; + const parseOutput = parser.parse(NonterminalKind.Tree, treeSource); + + const querySource = `[TreeNodeChild @id [DelimitedIdentifier]]`; + const query = Query.parse(querySource); + + const matches = parseOutput.createTreeCursor().query([query]); + + const expectNextMatch = (name: string) => { + const match = matches.next()!; + expect(Object.keys(match.captures)).toStrictEqual(["id"]); + + const cursors = match.captures["id"]!; + expect(cursors).toHaveLength(1); + + const node = cursors[0]!.node; + assertIsTerminalNode(node, TerminalKind.DelimitedIdentifier, name); + }; + + expectNextMatch("A"); + expectNextMatch("B"); + expectNextMatch("C"); + expectNextMatch("D"); + + expect(matches.next()).toBeUndefined(); +}); + +test("query syntax error", () => { + // there is no terminating ']' at the end of this query: + const source = `[TreeNode @b [DelimitedIdentifier]`; + + try { + Query.parse(source); + throw new Error("Query.parse() should have thrown"); + } catch (error) { + expect(error).toEqual({ + message: `Parse error: +expected ']' at: +Alt at: [TreeNode @b [DelimitedIdentifier] +`, + line: 0, + column: 34, + } satisfies QueryError); + } +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/cst/terminal-kind-extensions.mts b/crates/testlang/outputs/npm/tests/src/tests/cst/terminal-kind-extensions.mts new file mode 100644 index 0000000000..fe5b9cb9a9 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/cst/terminal-kind-extensions.mts @@ -0,0 +1,69 @@ +import { TerminalKindExtensions, TerminalKind } from "@slang-private/testlang-npm-package/cst"; + +describe("is_trivia()", () => { + for (const kind in TerminalKind) { + it(`TerminalKind.${kind}`, () => { + switch (kind) { + case TerminalKind.EndOfLine: + case TerminalKind.MultiLineComment: + case TerminalKind.SingleLineComment: + case TerminalKind.Whitespace: { + expect(TerminalKindExtensions.isTrivia(kind)).toBeTruthy(); + break; + } + case TerminalKind.Bang: + case TerminalKind.CloseBracket: + case TerminalKind.DelimitedIdentifier: + case TerminalKind.Identifier: + case TerminalKind.Missing: + case TerminalKind.OpenBracket: + case TerminalKind.Period: + case TerminalKind.Plus: + case TerminalKind.Semicolon: + case TerminalKind.StringLiteral: + case TerminalKind.TreeKeyword: + case TerminalKind.Unrecognized: { + expect(TerminalKindExtensions.isTrivia(kind)).toBeFalsy(); + break; + } + default: { + throw new Error(`Unexpected terminal kind: ${kind}`); + } + } + }); + } +}); + +describe("is_valid()", () => { + for (const kind in TerminalKind) { + it(`TerminalKind.${kind}`, () => { + switch (kind) { + case TerminalKind.Bang: + case TerminalKind.CloseBracket: + case TerminalKind.DelimitedIdentifier: + case TerminalKind.EndOfLine: + case TerminalKind.Identifier: + case TerminalKind.MultiLineComment: + case TerminalKind.OpenBracket: + case TerminalKind.Period: + case TerminalKind.Plus: + case TerminalKind.Semicolon: + case TerminalKind.SingleLineComment: + case TerminalKind.StringLiteral: + case TerminalKind.TreeKeyword: + case TerminalKind.Whitespace: { + expect(TerminalKindExtensions.isValid(kind)).toBeTruthy(); + break; + } + case TerminalKind.Missing: + case TerminalKind.Unrecognized: { + expect(TerminalKindExtensions.isValid(kind)).toBeFalsy(); + break; + } + default: { + throw new Error(`Unexpected terminal kind: ${kind}`); + } + } + }); + } +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/errors.ts b/crates/testlang/outputs/npm/tests/src/tests/errors.ts deleted file mode 100644 index c405695d7d..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/errors.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Parser } from "@slang-private/slang-testlang/parser"; -import { NonterminalKind, TextIndex } from "@slang-private/slang-testlang/cst"; -import { Severity } from "@slang-private/slang-testlang/diagnostic"; - -test("render error reports", () => { - const source = "tree [AB;"; - const parser = new Parser("1.0.0"); - - const errors = parser.parse(NonterminalKind.SourceUnit, source).errors(); - expect(errors).toHaveLength(1); - - expect(errors[0]!.severity()).toBe(Severity.Error); - expect(errors[0]!.message()).toBe("Expected Identifier or StringLiteral or TreeKeyword."); - expect(errors[0]!.textRange().start).toEqual({ utf8: 5, utf16: 5, column: 5, line: 0 } satisfies TextIndex); - expect(errors[0]!.textRange().end).toEqual({ utf8: 9, utf16: 9, column: 9, line: 0 } satisfies TextIndex); -}); - -test("invalid semantic version", () => { - expect(() => new Parser("foo_bar")).toThrow("Invalid semantic version 'foo_bar'."); -}); - -test("unsupported language version", () => { - expect(() => new Parser("0.0.0")).toThrow("Unsupported language version '0.0.0'."); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/parser/parse-error.mts b/crates/testlang/outputs/npm/tests/src/tests/parser/parse-error.mts new file mode 100644 index 0000000000..2af4d4d4ef --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/parser/parse-error.mts @@ -0,0 +1,20 @@ +import { Parser } from "@slang-private/testlang-npm-package/parser"; +import { NonterminalKind } from "@slang-private/testlang-npm-package/cst"; + +test("render error reports", () => { + const source = "tree [AB;"; + const parser = Parser.create("1.0.0"); + + const parseOutput = parser.parse(NonterminalKind.SourceUnit, source); + expect(parseOutput.isValid()).toBeFalsy(); + + const errors = parseOutput.errors; + expect(errors).toHaveLength(1); + + expect(errors[0]!.message).toBe("Expected Identifier or StringLiteral or TreeKeyword."); + + expect(errors[0]!.textRange).toEqual({ + start: { utf8: 5, utf16: 5, column: 5, line: 0 }, + end: { utf8: 9, utf16: 9, column: 9, line: 0 }, + }); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/parser/parse.mts b/crates/testlang/outputs/npm/tests/src/tests/parser/parse.mts new file mode 100644 index 0000000000..dea3c692e3 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/parser/parse.mts @@ -0,0 +1,57 @@ +import { Parser } from "@slang-private/testlang-npm-package/parser"; +import { + NonterminalKind, + TerminalKind, + assertIsNonterminalNode, + assertIsTerminalNode, +} from "@slang-private/testlang-npm-package/cst"; + +test("parse terminal", () => { + const source = "About_time"; + const parser = Parser.create("1.0.0"); + + const parseTree = parser.parse(NonterminalKind.TreeNodeChild, source).tree; + assertIsNonterminalNode(parseTree, NonterminalKind.TreeNodeChild); + + expect(parseTree.children).toHaveLength(1); + + assertIsTerminalNode(parseTree.children[0]!.node, TerminalKind.DelimitedIdentifier, "About_time"); +}); + +test("parse nonterminal", () => { + const source = `tree [A [B C] D];`; + const parser = Parser.create("1.0.0"); + + const parseTree = parser.parse(NonterminalKind.SourceUnit, source).tree; + assertIsNonterminalNode(parseTree, NonterminalKind.SourceUnit); + + expect(parseTree.children).toHaveLength(1); + + assertIsNonterminalNode(parseTree.children[0]!.node, NonterminalKind.SourceUnitMembers); +}); + +test("parse unicode characters", () => { + const source = `"some 😁 emoji"`; + const parser = Parser.create("1.0.0"); + + const nonTerminal = parser.parse(NonterminalKind.Literal, source).tree; + assertIsNonterminalNode(nonTerminal, NonterminalKind.Literal); + + expect(nonTerminal.textLength).toEqual({ + line: 0, + column: 14, + utf16: 15, + utf8: 17, + }); + + const terminal = nonTerminal.children[0]!.node; + + assertIsTerminalNode(terminal, TerminalKind.StringLiteral, `"some 😁 emoji"`); + + expect(terminal.textLength).toEqual({ + line: 0, + column: 14, + utf16: 15, + utf8: 17, + }); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/parser/root-kind.mts b/crates/testlang/outputs/npm/tests/src/tests/parser/root-kind.mts new file mode 100644 index 0000000000..c94db77514 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/parser/root-kind.mts @@ -0,0 +1,6 @@ +import { NonterminalKind } from "@slang-private/testlang-npm-package/cst"; +import { Parser } from "@slang-private/testlang-npm-package/parser"; + +test("Parser exposes a root kind", () => { + expect(Parser.rootKind()).toEqual(NonterminalKind.SourceUnit); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/parser/versions.mts b/crates/testlang/outputs/npm/tests/src/tests/parser/versions.mts new file mode 100644 index 0000000000..b07dc37e07 --- /dev/null +++ b/crates/testlang/outputs/npm/tests/src/tests/parser/versions.mts @@ -0,0 +1,18 @@ +import { Parser } from "@slang-private/testlang-npm-package/parser"; + +test("list supported versions", () => { + const versions = Parser.supportedVersions(); + + expect(versions.length).toBeGreaterThan(0); + + expect(versions.includes("1.0.0")).toBeTruthy(); + expect(versions.includes("0.0.0")).toBeFalsy(); +}); + +test("invalid semantic version", () => { + expect(() => Parser.create("foo_bar")).toThrow("Invalid semantic version: 'foo_bar'"); +}); + +test("unsupported language version", () => { + expect(() => Parser.create("0.0.0")).toThrow("Unsupported language version '0.0.0'."); +}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/public-api.ts b/crates/testlang/outputs/npm/tests/src/tests/public-api.ts deleted file mode 100644 index e1a1c3aeb1..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/public-api.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as slang from "@slang-private/slang-testlang"; -import { NonterminalKind, TerminalKind } from "@slang-private/slang-testlang/cst"; -import { Parser } from "@slang-private/slang-testlang/parser"; - -test("use namespace imports of the API", () => { - expect(slang.cst.NonterminalKind.SourceUnit).toEqual("SourceUnit"); - expect(slang.cst.NonterminalKind.TreeNode).toEqual("TreeNode"); - expect(slang.cst.TerminalKind.Identifier).toEqual("Identifier"); -}); - -test("use nested imports of the API", () => { - expect(NonterminalKind.SourceUnit).toEqual("SourceUnit"); - expect(NonterminalKind.TreeNode).toEqual("TreeNode"); - expect(TerminalKind.Identifier).toEqual("Identifier"); -}); - -test("language exposes a root kind", () => { - expect(Parser.rootKind()).toEqual(NonterminalKind.SourceUnit); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/query.ts b/crates/testlang/outputs/npm/tests/src/tests/query.ts deleted file mode 100644 index 964e601812..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/query.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { NonterminalKind, TerminalKind, Query } from "@slang-private/slang-testlang/cst"; -import { Parser } from "@slang-private/slang-testlang/parser"; -import { expectTerminal } from "../utils/cst-helpers"; - -test("simple query", () => { - const parser = new Parser("1.0.0"); - const tree_source = `tree [A [B C] D];`; - const parse_output = parser.parse(NonterminalKind.Tree, tree_source); - - const query_source = `[TreeNodeChild @id [DelimitedIdentifier]]`; - const query = Query.parse(query_source); - - const matches = parse_output.createTreeCursor().query([query]); - - const expectNextMatch = (name: string) => { - let match = matches.next(); - expect(match).not.toBeNull(); - expect(Object.keys(match!.captures)).toStrictEqual(["id"]); - let cursors = match!.captures["id"]!; - expect(cursors.length).toEqual(1); - expectTerminal(cursors[0]!.node(), TerminalKind.DelimitedIdentifier, name); - }; - - expectNextMatch("A"); - expectNextMatch("B"); - expectNextMatch("C"); - expectNextMatch("D"); - - expect(matches.next()).toBeNull(); -}); - -test("parser error", () => { - const source = `[TreeNode @b [DelimitedIdentifier]`; - // The exact error message is not important, just that it throws. - expect(() => Query.parse(source)).toThrow(); -}); diff --git a/crates/testlang/outputs/npm/tests/src/tests/versions.ts b/crates/testlang/outputs/npm/tests/src/tests/versions.ts deleted file mode 100644 index cb03ac1213..0000000000 --- a/crates/testlang/outputs/npm/tests/src/tests/versions.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Parser } from "@slang-private/slang-testlang/parser"; - -test("list supported versions", () => { - const versions = Parser.supportedVersions(); - - expect(versions.length).toBeGreaterThan(0); - - expect(versions.includes("1.0.0")).toBeTruthy(); - expect(versions.includes("0.0.0")).toBeFalsy(); -}); diff --git a/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts b/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts deleted file mode 100644 index 90ca337240..0000000000 --- a/crates/testlang/outputs/npm/tests/src/utils/cst-helpers.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { - NodeType, - NonterminalKind, - NonterminalNode, - TerminalKind, - TerminalNode, -} from "@slang-private/slang-testlang/cst"; - -export function expectNonterminal(node: unknown, kind: NonterminalKind): asserts node is NonterminalNode { - expect(node).toBeInstanceOf(NonterminalNode); - - const nonTerminal = node as NonterminalNode; - expect(nonTerminal.type).toEqual(NodeType.Nonterminal); - expect(nonTerminal.kind).toEqual(kind); -} - -export function expectTerminal(node: unknown, kind: TerminalKind, text: string): asserts node is TerminalNode { - expect(node).toBeInstanceOf(TerminalNode); - - const terminal = node as TerminalNode; - expect(terminal.type).toEqual(NodeType.Terminal); - expect(terminal.kind).toEqual(kind); - expect(terminal.text).toEqual(text); -} diff --git a/crates/testlang/outputs/npm/tests/src/utils/files.ts b/crates/testlang/outputs/npm/tests/src/utils/files.ts deleted file mode 100644 index 3d356a1bcc..0000000000 --- a/crates/testlang/outputs/npm/tests/src/utils/files.ts +++ /dev/null @@ -1,9 +0,0 @@ -import assert from "node:assert"; -import path from "node:path"; - -export function repoPath(relativePath: string): string { - const repoRoot = process.env["REPO_ROOT"]; - assert(repoRoot); - - return path.join(repoRoot, relativePath); -} diff --git a/crates/testlang/outputs/npm/tests/tsconfig.json b/crates/testlang/outputs/npm/tests/tsconfig.json index bbddcbbc34..7b4d9a1ad1 100644 --- a/crates/testlang/outputs/npm/tests/tsconfig.json +++ b/crates/testlang/outputs/npm/tests/tsconfig.json @@ -1,16 +1,9 @@ { "extends": "../../../../../tsconfig.json", - "include": ["./src/**/*.ts", "./jest.config.ts"], + "include": ["./**/*"], "compilerOptions": { - /* Modules */ - "paths": { - // __SLANG_NPM_PACKAGE_MAIN_OUTPUT_DIR__ (keep in sync) - "@slang-private/slang-testlang": ["../package/target/npm/main"], - "@slang-private/slang-testlang/*": ["../package/target/npm/main/*"] - }, - /* Projects */ "composite": true, "incremental": true, diff --git a/documentation/public/assets/javascripts/tsconfig.json b/documentation/public/assets/javascripts/tsconfig.json index e6fd7150d0..df57ca9994 100644 --- a/documentation/public/assets/javascripts/tsconfig.json +++ b/documentation/public/assets/javascripts/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../../../tsconfig.json", - "include": ["./**/*.js"], + "include": ["./**/*"], "compilerOptions": { /* Projects */ diff --git a/documentation/public/user-guide/npm-package/using-queries.md b/documentation/public/user-guide/npm-package/using-queries.md index a3278fe982..07599407f9 100644 --- a/documentation/public/user-guide/npm-package/using-queries.md +++ b/documentation/public/user-guide/npm-package/using-queries.md @@ -13,7 +13,7 @@ You can create a `Query` object using `Query.parse`, which accepts a string valu You can pass multiple queries to a cursor to and efficiently traverse the tree looking for matches. They will be executed concurrently, returning matches in the order they appear in input. ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:creating-a-query" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:creating-a-query" ``` ## Iterating over node patterns @@ -27,7 +27,7 @@ Let's use this to list all the contract definitions in the source file: ``` ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:visiting-contracts" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:visiting-contracts" ``` ### Multiple patterns simultaneously @@ -35,7 +35,7 @@ Let's use this to list all the contract definitions in the source file: We can also intersperse multiple patterns in a single query, which will return all the matches for each pattern. This can be useful when you want to match multiple types of nodes in a single pass. ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:multiple-patterns" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:multiple-patterns" ``` ## Matching on node's label @@ -49,7 +49,7 @@ To do so, we use `[label: _]` syntax. Here, we also use `_` to allow matching an ``` ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:matching-on-label" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:matching-on-label" ``` ## Matching on node's literal content @@ -63,7 +63,7 @@ Let's say we prefer our code to be explicit and prefer using `uint256` instead o ``` ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:matching-on-literal-value" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:matching-on-literal-value" ``` ## Example: Finding `tx.origin` patterns @@ -79,5 +79,5 @@ Let's use the motivating example from [https://soliditylang.org](https://docs.so Now, we can above features to write a query that matches all `tx.origin` patterns: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.ts:tx-origin" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-queries.mts:tx-origin" ``` diff --git a/documentation/public/user-guide/npm-package/using-the-ast.md b/documentation/public/user-guide/npm-package/using-the-ast.md index afd023821f..2acb36c420 100644 --- a/documentation/public/user-guide/npm-package/using-the-ast.md +++ b/documentation/public/user-guide/npm-package/using-the-ast.md @@ -11,26 +11,26 @@ to create the CST type. Since it is a node of kind `FunctionDefinition`, we are the AST type of the same name to analyze it: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts:imports" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts:imports" ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts:parse-input" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts:parse-input" ``` The `FunctionDefinition` type has named fields to access all its children. For example, we can check the name of the function: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts:create-node" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts:create-node" ``` We can also list its parameters: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts:list-parameters" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts:list-parameters" ``` Or attributes: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.ts:list-attributes" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-ast.mts:list-attributes" ``` diff --git a/documentation/public/user-guide/npm-package/using-the-cursor.md b/documentation/public/user-guide/npm-package/using-the-cursor.md index 8244119657..28aba2308c 100644 --- a/documentation/public/user-guide/npm-package/using-the-cursor.md +++ b/documentation/public/user-guide/npm-package/using-the-cursor.md @@ -8,9 +8,9 @@ Let's start with this source file, that contains three contracts: ``` ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts:imports" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts:imports" ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts:parse-input" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts:parse-input" ``` ## Listing Contract Names @@ -18,7 +18,7 @@ Let's start with this source file, that contains three contracts: The below example uses a cursor to list the names of all contracts in a source file: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts:listing-contract-names" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts:listing-contract-names" ``` ## Visiting Only a Sub-tree @@ -32,7 +32,7 @@ which cheaply creates a new cursor that starts at the given node, without copyin This lets us visit the sub-tree of each contract, without modifying the original cursor: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts:visiting-sub-tree" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts:visiting-sub-tree" ``` ## Accessing Node Positions @@ -41,5 +41,5 @@ The `Cursor` API also tracks the position and range of the current node it is vi Here is an example that records the source range of each contract, along with its text: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.ts:accessing-node-positions" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-cursor.mts:accessing-node-positions" ``` diff --git a/documentation/public/user-guide/npm-package/using-the-parser.md b/documentation/public/user-guide/npm-package/using-the-parser.md index 95bc8a2afa..b4b5e3b72d 100644 --- a/documentation/public/user-guide/npm-package/using-the-parser.md +++ b/documentation/public/user-guide/npm-package/using-the-parser.md @@ -14,9 +14,9 @@ We begin by creating a `Parser` object with a specified version. This is an entr Then we can use it to parse the source file, specifying the top-level nonterminal to parse: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:imports" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:imports" ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:parse-input" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:parse-input" ``` ## Checking for Syntax Errors @@ -24,13 +24,13 @@ Then we can use it to parse the source file, specifying the top-level nontermina If the file has errors, we can get them from the `ParseOutput` type, and print them out: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:print-errors" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:print-errors" ``` Otherwise, we can check if input is valid using this helpful utility: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:assert-is-valid" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:assert-is-valid" ``` ## Inspecting the Parse Tree @@ -38,11 +38,11 @@ Otherwise, we can check if input is valid using this helpful utility: Now, let's try to inspect the resulting CST, and iterate on its children: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:inspect-tree" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:inspect-tree" ``` Additionally, we can convert the CST node back into the input string: ```{ .ts } ---8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.ts:unparse-node" +--8<-- "crates/solidity/outputs/npm/tests/src/doc-examples/using-the-parser.mts:unparse-node" ``` diff --git a/package-lock.json b/package-lock.json index efa18aab33..4ea38bc3e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,18 +6,9 @@ "": { "name": "@slang-private/workspace", "workspaces": [ - "crates/codegen/runtime/npm", + "crates/codegen/runtime/npm/package", "crates/infra/cli", "crates/solidity/outputs/npm/package", - "crates/solidity/outputs/npm/package/platforms/darwin-arm64", - "crates/solidity/outputs/npm/package/platforms/darwin-x64", - "crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu", - "crates/solidity/outputs/npm/package/platforms/linux-arm64-musl", - "crates/solidity/outputs/npm/package/platforms/linux-x64-gnu", - "crates/solidity/outputs/npm/package/platforms/linux-x64-musl", - "crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc", - "crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc", - "crates/solidity/outputs/npm/package/platforms/win32-x64-msvc", "crates/solidity/outputs/npm/tests", "crates/solidity/testing/perf", "crates/testlang/outputs/npm/package", @@ -33,6 +24,12 @@ "node": ">= 10" } }, + "crates/codegen/runtime/npm/package": { + "name": "@slang-private/codegen-runtime-npm-package", + "dependencies": { + "@bytecodealliance/preview2-shim": "0.17.0" + } + }, "crates/infra/cli": { "name": "@slang-private/infra-cli", "devDependencies": { @@ -56,101 +53,19 @@ "version": "0.17.0", "license": "MIT", "dependencies": { - "@nomicfoundation/slang-darwin-arm64": "0.17.0", - "@nomicfoundation/slang-darwin-x64": "0.17.0", - "@nomicfoundation/slang-linux-arm64-gnu": "0.17.0", - "@nomicfoundation/slang-linux-arm64-musl": "0.17.0", - "@nomicfoundation/slang-linux-x64-gnu": "0.17.0", - "@nomicfoundation/slang-linux-x64-musl": "0.17.0", - "@nomicfoundation/slang-win32-arm64-msvc": "0.17.0", - "@nomicfoundation/slang-win32-ia32-msvc": "0.17.0", - "@nomicfoundation/slang-win32-x64-msvc": "0.17.0" - }, - "devDependencies": { - "@napi-rs/cli": "2.18.4" - }, - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/darwin-arm64": { - "name": "@nomicfoundation/slang-darwin-arm64", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/darwin-x64": { - "name": "@nomicfoundation/slang-darwin-x64", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu": { - "name": "@nomicfoundation/slang-linux-arm64-gnu", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/linux-arm64-musl": { - "name": "@nomicfoundation/slang-linux-arm64-musl", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/linux-x64-gnu": { - "name": "@nomicfoundation/slang-linux-x64-gnu", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/linux-x64-musl": { - "name": "@nomicfoundation/slang-linux-x64-musl", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc": { - "name": "@nomicfoundation/slang-win32-arm64-msvc", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc": { - "name": "@nomicfoundation/slang-win32-ia32-msvc", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" - } - }, - "crates/solidity/outputs/npm/package/platforms/win32-x64-msvc": { - "name": "@nomicfoundation/slang-win32-x64-msvc", - "version": "0.17.0", - "license": "MIT", - "engines": { - "node": ">= 10" + "@bytecodealliance/preview2-shim": "0.17.0" } }, "crates/solidity/outputs/npm/tests": { "name": "@slang-private/solidity-npm-tests", + "dependencies": { + "@nomicfoundation/slang": "file:../package" + }, "devDependencies": { "@types/jest": "29.5.13", "jest": "29.7.0", "ts-jest": "29.2.5", + "ts-jest-resolver": "2.0.1", "ts-node": "10.9.2" } }, @@ -167,20 +82,21 @@ "dev": true }, "crates/testlang/outputs/npm/package": { - "name": "@slang-private/slang-testlang", - "devDependencies": { - "@napi-rs/cli": "2.18.4" - }, - "engines": { - "node": ">= 10" + "name": "@slang-private/testlang-npm-package", + "dependencies": { + "@bytecodealliance/preview2-shim": "0.17.0" } }, "crates/testlang/outputs/npm/tests": { "name": "@slang-private/testlang-npm-tests", + "dependencies": { + "@slang-private/testlang-npm-package": "file:../package" + }, "devDependencies": { "@types/jest": "29.5.13", "jest": "29.7.0", "ts-jest": "29.2.5", + "ts-jest-resolver": "2.0.1", "ts-node": "10.9.2" } }, @@ -729,6 +645,12 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@bytecodealliance/preview2-shim": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@bytecodealliance/preview2-shim/-/preview2-shim-0.17.0.tgz", + "integrity": "sha512-JorcEwe4ud0x5BS/Ar2aQWOQoFzjq/7jcnxYXCvSMh0oRm0dQXzOA+hqLDBnOMks1LLBA7dmiLLsEBl09Yd6iQ==", + "license": "(Apache-2.0 WITH LLVM-exception)" + }, "node_modules/@changesets/apply-release-plan": { "version": "7.0.5", "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.5.tgz", @@ -2283,14 +2205,14 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dev": true, "dependencies": { - "@jridgewell/set-array": "^1.0.1", + "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" @@ -2306,9 +2228,9 @@ } }, "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "dev": true, "engines": { "node": ">=6.0.0" @@ -2321,9 +2243,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.22", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz", - "integrity": "sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -2396,22 +2318,6 @@ "node": ">=6 <7 || >=8" } }, - "node_modules/@napi-rs/cli": { - "version": "2.18.4", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.4.tgz", - "integrity": "sha512-SgJeA4df9DE2iAEpr3M2H0OKl/yjtg1BnRI5/JyowS71tUWhrfSu2LT0V3vlHET+g1hBVlrO60PmEXwUEKp8Mg==", - "dev": true, - "bin": { - "napi": "scripts/index.js" - }, - "engines": { - "node": ">= 10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2451,42 +2357,6 @@ "resolved": "crates/solidity/outputs/npm/package", "link": true }, - "node_modules/@nomicfoundation/slang-darwin-arm64": { - "resolved": "crates/solidity/outputs/npm/package/platforms/darwin-arm64", - "link": true - }, - "node_modules/@nomicfoundation/slang-darwin-x64": { - "resolved": "crates/solidity/outputs/npm/package/platforms/darwin-x64", - "link": true - }, - "node_modules/@nomicfoundation/slang-linux-arm64-gnu": { - "resolved": "crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu", - "link": true - }, - "node_modules/@nomicfoundation/slang-linux-arm64-musl": { - "resolved": "crates/solidity/outputs/npm/package/platforms/linux-arm64-musl", - "link": true - }, - "node_modules/@nomicfoundation/slang-linux-x64-gnu": { - "resolved": "crates/solidity/outputs/npm/package/platforms/linux-x64-gnu", - "link": true - }, - "node_modules/@nomicfoundation/slang-linux-x64-musl": { - "resolved": "crates/solidity/outputs/npm/package/platforms/linux-x64-musl", - "link": true - }, - "node_modules/@nomicfoundation/slang-win32-arm64-msvc": { - "resolved": "crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc", - "link": true - }, - "node_modules/@nomicfoundation/slang-win32-ia32-msvc": { - "resolved": "crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc", - "link": true - }, - "node_modules/@nomicfoundation/slang-win32-x64-msvc": { - "resolved": "crates/solidity/outputs/npm/package/platforms/win32-x64-msvc", - "link": true - }, "node_modules/@octokit/auth-token": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz", @@ -2639,16 +2509,12 @@ "@sinonjs/commons": "^3.0.0" } }, - "node_modules/@slang-private/infra-cli": { - "resolved": "crates/infra/cli", - "link": true - }, - "node_modules/@slang-private/slang-codegen-runtime": { - "resolved": "crates/codegen/runtime/npm", + "node_modules/@slang-private/codegen-runtime-npm-package": { + "resolved": "crates/codegen/runtime/npm/package", "link": true }, - "node_modules/@slang-private/slang-testlang": { - "resolved": "crates/testlang/outputs/npm/package", + "node_modules/@slang-private/infra-cli": { + "resolved": "crates/infra/cli", "link": true }, "node_modules/@slang-private/solidity-npm-tests": { @@ -2659,6 +2525,10 @@ "resolved": "crates/solidity/testing/perf", "link": true }, + "node_modules/@slang-private/testlang-npm-package": { + "resolved": "crates/testlang/outputs/npm/package", + "link": true + }, "node_modules/@slang-private/testlang-npm-tests": { "resolved": "crates/testlang/outputs/npm/tests", "link": true @@ -9269,6 +9139,16 @@ } } }, + "node_modules/ts-jest-resolver": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ts-jest-resolver/-/ts-jest-resolver-2.0.1.tgz", + "integrity": "sha512-FolE73BqVZCs8/RbLKxC67iaAtKpBWx7PeLKFW2zJQlOf9j851I7JRxSDenri2NFvVH3QP7v3S8q1AmL24Zb9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-resolve": "^29.5.0" + } + }, "node_modules/ts-jest/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", diff --git a/package.json b/package.json index 2e120ab965..0c7ca0c150 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,9 @@ "name": "@slang-private/workspace", "private": true, "workspaces": [ - "crates/codegen/runtime/npm", + "crates/codegen/runtime/npm/package", "crates/infra/cli", "crates/solidity/outputs/npm/package", - "crates/solidity/outputs/npm/package/platforms/darwin-arm64", - "crates/solidity/outputs/npm/package/platforms/darwin-x64", - "crates/solidity/outputs/npm/package/platforms/linux-arm64-gnu", - "crates/solidity/outputs/npm/package/platforms/linux-arm64-musl", - "crates/solidity/outputs/npm/package/platforms/linux-x64-gnu", - "crates/solidity/outputs/npm/package/platforms/linux-x64-musl", - "crates/solidity/outputs/npm/package/platforms/win32-arm64-msvc", - "crates/solidity/outputs/npm/package/platforms/win32-ia32-msvc", - "crates/solidity/outputs/npm/package/platforms/win32-x64-msvc", "crates/solidity/outputs/npm/tests", "crates/solidity/testing/perf", "crates/testlang/outputs/npm/package", diff --git a/scripts/bin/infra b/scripts/bin/infra index 7147f73c30..267f48dedf 100755 --- a/scripts/bin/infra +++ b/scripts/bin/infra @@ -11,7 +11,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../_common.sh" # Additionally, we cannot use 'cargo run --bin infra_cli' directly, because 'cargo run' sets a bunch # of 'CARGO_*' environment variables, and they get propagated to any child `cargo` commands that are # spawned by 'infra_cli'. We have to build and run the binary directly to ensure it has a clean env. -# Otherwise, they leak into things like cross-platform NAPI builds, and cause build failures. +# Otherwise, they leak into cross-platform or multi-target builds, and cause build failures. # ( diff --git a/submodules/jco b/submodules/jco new file mode 160000 index 0000000000..6b47533932 --- /dev/null +++ b/submodules/jco @@ -0,0 +1 @@ +Subproject commit 6b47533932834d86b470e0a46cf1d6305238e4dd diff --git a/tsconfig.json b/tsconfig.json index 2f26f7b9ab..696a8dbc60 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ ], "references": [ - { "path": "./crates/codegen/runtime/npm/tsconfig.json" }, + { "path": "./crates/codegen/runtime/npm/package/tsconfig.json" }, { "path": "./crates/solidity/outputs/npm/package/tsconfig.json" }, { "path": "./crates/solidity/outputs/npm/tests/tsconfig.json" }, { "path": "./crates/testlang/outputs/npm/package/tsconfig.json" }, @@ -45,8 +45,8 @@ "useUnknownInCatchVariables": true, /* Modules */ - "module": "Node16", - "moduleResolution": "Node16", + "module": "NodeNext", + "moduleResolution": "NodeNext", /* Emit */ "noEmit": true, @@ -60,8 +60,7 @@ "esModuleInterop": true, /* Language and Environment */ - "target": "ES2016", - "lib": ["DOM", "DOM.Iterable"], + "target": "ES6", /* Projects */ "composite": true,